Parse the XML file for multiple nodes in the following format:
<?XML version= "1.0" encoding= "Utf-8"?><Response> <Flag>Success</Flag> <Code>1</Code> <message>Success singular: 1 failure singular: 0</message> <Items> <Item> <Warecode>ABC</Warecode> <ItemCode>1000100</ItemCode> <itemId>11111236</itemId> <Inventorytype>ZP</Inventorytype> <Quantity>235</Quantity> <lockquantity>0</lockquantity> </Item> </Items></Response>
Parse the message code:
The nodes in the response are then traversed, and then the node traversal in item is removed.
varStrresponse = fromItemresponseinchXdoc.descendants ("Response") SelectItemresponse; foreach(varItemsinchstrresponse) { stringStatus = Items. Element ("Flag"). Value; if(Status = ="Success") { varItemresponse = fromItemquantityinchXdoc.descendants ("Item") Selectitemquantity; foreach(varIteminchitemresponse) {obj. PRODUCT_UPC= Item. Element ("ItemCode"). Value; Obj. Product_kd_prodcode= Item. Element ("itemId"). Value; Obj. QUANTITY= Convert.toint64 (item. Element ("Quantity"). Value); Obj. product_id=PROD_KD. product_id; Obj. Lockquantity= Convert.toint64 (item. Element ("lockquantity"). Value); Obj. Product_code=PROD_KD. Product_code; Obj. Product_Name=PROD_KD. Product_Name; } } }
XML parsing multiple node methods (C #)