Outputting XML Elements Only In A Certain File

Hello,

I’ve been having a problem with comparing two similar XML files. My main objective with this is to compare the megacorpInfo.xml and megacorpinfocomp.xml (sorry about similar names, was lazy about naming them), and get elements only in the megacorpInfocomp.xml file and then output that to another text file.

Here are the two files I’m comparing.

megacorpInfocomp.xml (32.0 KB)
megacorpInfo.xml (15.2 KB)

Help would be greatly appreciated.

Thanks.

HI,

Can you also share expected output?

Regards,

1 Like

The expected output would be a text file with the elements (unique “Details-Collection” and anything inside that) only found in the megacorpInfocomp.xml. I haven’t made that file yet, but we can call it something like megacorp_New.xml.

HI,

Can you explain more specific with sample?

For example, do you need only quickpay element even if other value of element is different?

Regards,

1 Like

Hi,

quickpay should be in every detail-collection, that might be an error on my part.

I don’t need to know any of the elements values/attributes besides the Detail-Collection’s PO-number to compare it between both files (might compare the PO-Number tag value if that doesn’t work). All I’m trying to get is the Detail-Collections and its descendants only found within the megacorpInfocomp.xml.

So you can say I only need to know the unique detail-collection tags.

Thanks.

HI,

How about the following?

ieResult = ieDetailCollectionComp.Where(Function(x) not ieDetailCollection.Any(Function(x2) x2.Attribute("POnumber").Value=x.Attribute("POnumber").Value)).ToArray

Sample20230302-4L.zip (7.8 KB)

Regards,

1 Like

Hi,

This is exactly what I’m looking for!

Thank you @Yoichi, you’re doing really good work.

Thanks,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.