By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,952 Members | 1,570 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,952 IT Pros & Developers. It's quick & easy.

How to read the XML node and compare two XML documets

P: n/a
Hello,
I want to read two XML documents and compare the nodes. And I want to
Modify the second XML File by deleting the Node.
Here in the Example bothe Files has MessageID as common and If i see the
MessageID Result Code Error then I need to Delete it from the First.

How do I do this ....

Thanks
Naveen.
Example :
One.xml
<Message>
<MessageID>1</MessageID>
<Relationship>
<ParentSKU>0113311000000</ParentSKU>
<Relation>
<SKU>0113508000000</SKU>
<Type>Accessory</Type>
</Relation>
</Relationship>
</MessageID>
</Message>

Two.xml

<Result>
<MessageID>1</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>8008</ResultMessageCode>
<ResultDescription>The entry for SKU [0400235000000] contains an
invalid or unrecognized SKU. Please correct the SKU and resubmit
the item with your next feed. The item will appear with the next catalog
build.</ResultDescription>
</Result>


Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
dd
Load your second XML into XMLDoc object. Select all nodes that have "Error"
in "ResultCode" and read their ID's. Load your first XML into and XMLDoc
object, select and delete all nodes that have the ID's collected in the
first XMLDoc.

"Naga" <na*********@hotmail.com> wrote in message
news:OK****************@TK2MSFTNGP12.phx.gbl...
Hello,
I want to read two XML documents and compare the nodes. And I want to
Modify the second XML File by deleting the Node.
Here in the Example bothe Files has MessageID as common and If i see the
MessageID Result Code Error then I need to Delete it from the First.

How do I do this ....

Thanks
Naveen.
Example :
One.xml
<Message>
<MessageID>1</MessageID>
<Relationship>
<ParentSKU>0113311000000</ParentSKU>
<Relation>
<SKU>0113508000000</SKU>
<Type>Accessory</Type>
</Relation>
</Relationship>
</MessageID>
</Message>

Two.xml

<Result>
<MessageID>1</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>8008</ResultMessageCode>
<ResultDescription>The entry for SKU [0400235000000] contains an
invalid or unrecognized SKU. Please correct the SKU and resubmit
the item with your next feed. The item will appear with the next catalog
build.</ResultDescription>
</Result>


Nov 15 '05 #2

P: n/a
dd
Load your second XML into XMLDoc object. Select all nodes that have "Error"
in "ResultCode" and read their ID's. Load your first XML into and XMLDoc
object, select and delete all nodes that have the ID's collected in the
first XMLDoc.

"Naga" <na*********@hotmail.com> wrote in message
news:OK****************@TK2MSFTNGP12.phx.gbl...
Hello,
I want to read two XML documents and compare the nodes. And I want to
Modify the second XML File by deleting the Node.
Here in the Example bothe Files has MessageID as common and If i see the
MessageID Result Code Error then I need to Delete it from the First.

How do I do this ....

Thanks
Naveen.
Example :
One.xml
<Message>
<MessageID>1</MessageID>
<Relationship>
<ParentSKU>0113311000000</ParentSKU>
<Relation>
<SKU>0113508000000</SKU>
<Type>Accessory</Type>
</Relation>
</Relationship>
</MessageID>
</Message>

Two.xml

<Result>
<MessageID>1</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>8008</ResultMessageCode>
<ResultDescription>The entry for SKU [0400235000000] contains an
invalid or unrecognized SKU. Please correct the SKU and resubmit
the item with your next feed. The item will appear with the next catalog
build.</ResultDescription>
</Result>


Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.