Hello,
Thanks for the response Oleg. Now I need to know few answers. How do I
get the value of a node using the xpath. I want the value of the MessageID
and ResultCode from secondxml. And using this I want to delete the Child
Nodes in the firstxml document.
I am using the fowllowing code but the ni.current.value has values of all
nodes in the file. I am confused.
XmlDocument doc = new XmlDocument();
doc.Load("Firstxml.xml")
hDocument doc2 = new XPathDocument("second.xml");
XPathNavigator nav = doc2.CreateNavigator();
foreach (XmlNode msg in doc.SelectNodes("//Message"))
{
XPathNodeIterator ni = nav.Select("/Result[MessageID='" +
msg.SelectSingleNode("MessageID/text()").Value +
"']/ResultCode");
ni.MoveNext();
if (ni.Current.Value == "Error")
msg.ParentNode.RemoveChild(msg);
}
1. My FirstXML Document Looks Like this.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<AE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="az-envelope.xsd">
<Header>
<DocumentVersion>1.0</DocumentVersion>
<MerchantIdentifier>M_493</MerchantIdentifier>
</Header>
<MessageType>Relationship</MessageType>
<Message>
<MessageID>1</MessageID>
<Relationship>
<ParentSKU>0113311000000</ParentSKU>
<Relation><SKU>0113508000000</SKU><Type>Accessory</Type></Relation>
<Relation><SKU>0113630000000</SKU><Type>Accessory</Type></Relation>
</Relationship>
<MessageID>2</MessageID>
<Relationship>
<ParentSKU>0113312000000</ParentSKU>
<Relation><SKU>0113312048305</SKU><Type>Variation</Type></Relation>
<Relation><SKU>0113312048306</SKU><Type>Variation</Type></Relation>
</Relationship>
<MessageID>3</MessageID>
<Relationship>
<ParentSKU>0113312000000</ParentSKU>
<Relation><SKU>0113312048305</SKU><Type>Variation</Type></Relation>
<Relation><SKU>0113312048306</SKU><Type>Variation</Type></Relation>
</Relationship>
</Message>
</AE>
2. My secondXML look like this.
<?xml version="1.0" encoding="UTF-8"?>
<AE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_493</MerchantIdentifier>
</Header>
<MessageType>ProcessingReport</MessageType>
<Message>
<MessageID>1</MessageID>
<ProcessingReport>
<DocumentTransactionID>30035573</DocumentTransactionID>
<StatusCode>Complete</StatusCode>
<ProcessingSummary>
<MessagesProcessed>921</MessagesProcessed>
<MessagesSuccessful>686</MessagesSuccessful>
<MessagesWithError>235</MessagesWithError>
<MessagesWithWarning>0</MessagesWithWarning>
</ProcessingSummary>
<Result>
<MessageID>17</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>
<Result>
<MessageID>17</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>8008</ResultMessageCode>
<ResultDescription>The entry for SKU [113122B000000] 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>
<Result>
<MessageID>24</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>8008</ResultMessageCode>
<ResultDescription>The entry for SKU [0535508000000] 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>
<Result>
<MessageID>24</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>8008</ResultMessageCode>
<ResultDescription>The entry for SKU [0535630000000] 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>
<Result>
<MessageID>24</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>8016</ResultMessageCode>
<ResultDescription>Elements are missing in [ 0113534235039 ] to establish
relationships appropriately. Please check the
VariationTheme and make sure the variations elements match what is
declared.</ResultDescription>
</Result>
<Result>
<MessageID>27</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>8008</ResultMessageCode>
<ResultDescription>The entry for SKU [0400358000000] 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>
<Result>
<MessageID>36</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>8008</ResultMessageCode>
<ResultDescription>The entry for SKU [0121501000000] 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></ProcessingReport>
</Message>
</AE>