Announcement

Collapse
No announcement yet.

Ignoring empty XML elements

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ignoring empty XML elements



    I am comparing two xml files and want to ignore empty xml elements since they may be slightly different in the two files but the difference is not important to my application. For example:
    File 1: <XXX></XXX> File 2: <XXX />
    What would the grammar be to tell beyond compare to ignore if one file has an empty tag as one of the above and the other file has the other. It would also be great if I could also ignore it if there is a empty tag in one file and nothing in the other file.

    Sorry if this has been asked but I was unable to find an answer with search or google.

    Thanks for any help!

  • #2
    Hello,

    You can define a Text Replacement with BC4 Pro, which can define a specific sided change and mark it as Unimportant. If you are registered for Std edition, revert to trial mode to test first here:
    http://www.scootersoftware.com/suppo...?zz=kb_evalpro

    In the Text Compare's Session menu -> Session Settings, Misc tab, create a new Replacement:
    [<]([^>]+)[>][<][/].*[>]
    with
    <$1 />
    enable Regular Expression.

    How does this work for you?
    Aaron P Scooter Software

    Comment


    • #3
      I own BC4 Pro so I will give it a go and report back.

      Thanks!

      Comment


      • #4
        Did not work. See screen shot. I selected Reg Exp and saved the settings. See below
        Click image for larger version

Name:	Capture.JPG
Views:	191
Size:	63.1 KB
ID:	82540

        Comment


        • #5
          Hello,

          It is a sided definition, and it looks like you have the double node side on the right side of the screenshot. You would need to define it again and select "Right" as the side, so you have two entries in the Replacements tab: one for left to right and one for right to left. Given how the Regular Expression works, it is usually required or easier to define the longer side as the Find side, and the shorter side as the Replace With side, then change the Side to Left or Right as appropriate.
          Aaron P Scooter Software

          Comment


          • #6
            Originally posted by Aaron View Post
            Hello,

            It is a sided definition, and it looks like you have the double node side on the right side of the screenshot. You would need to define it again and select "Right" as the side, so you have two entries in the Replacements tab: one for left to right and one for right to left. Given how the Regular Expression works, it is usually required or easier to define the longer side as the Find side, and the shorter side as the Replace With side, then change the Side to Left or Right as appropriate.
            That worked for the File 1: <XXX /> File 2: <XXX></XXX>

            Is there a way to handle:

            File 1: <XXX> File 2:

            Where an empty tag has no tag in the other file?

            Comment


            • #7
              The Text Replacement feature does not support matching on "nothing". This would have to be a general Unimportant definition, but that would make any node text unimportant, which I don't think you were trying to define.
              Aaron P Scooter Software

              Comment

              Working...
              X