(Please see attached files)
I have built a code to add “Invoice_Line_Replacement_Data” node again in the xml file .
While doing that I was facing issues in adding 2 lines of nodes there wiz.
(Here I also want to update the value of wd:parent_id everyone (PO-00007288) as well as insert the line number )
2. <wd:ID wd:type=“Region_Reference_ID”>BRA</wd:ID>
(Here I want to update the region.For eg.BRA)
Similarly I want to delete these nodes also - I tried invoking “Remove” build was not able to do it -
(Is it possible to remove the node and its attributes entirely) since I want to remove this entire data in some cases wd:Invoice_Line_Replacement_Data wd:Purchase_Order_Line_Reference
<wd:ID wd:type=“Line_Number” wd:parent_id=“PO-00007288” wd:parent_type=“Document_Number”>3</wd:ID>
</wd:Purchase_Order_Line_Reference> wd:Quantity1</wd:Quantity> wd:Unit_Cost4.07</wd:Unit_Cost> wd:Worktags_Reference
<wd:ID wd:type=“Region_Reference_ID”>BRA</wd:ID>
</wd:Worktags_Reference> wd:Worktags_Reference
<wd:ID wd:type=“Cost_Center_Reference_ID”>CC2342343809</wd:ID>
</wd:Worktags_Reference>
</wd:Invoice_Line_Replacement_Data>
In some cases only wd:Worktags_Reference
<wd:ID wd:type=“Cost_Center_Reference_ID”>CC2342343809</wd:ID>
</wd:Worktags_Reference>
One thing that has worked with my workday use cases is parsing the Xml as an XDocument, which will allow you to slice, dice and play around. Being part of System.Xml.Linq you should be able use lambdas at your convenience. See the references below for in-depth documentation.
/* this code sample is not the solution is just an example to showcase the XDocument Class
the code below gets specific nodes from an XDocument using lambda
Remember every node can be parsed as an XDocument
In this example I'm extracting the "Attachment_Data" nodes
xml_text variable is my XDocument */
extracted_nodes = xml_text.Descendants.Where(Function (element) element.Name.ToString.Contains("Attachment_Data")
(Here I also want to update the value of wd:parent_id everyone (PO-00007288) as well as insert the line number )
2. <wd:ID wd:type=“Region_Reference_ID”>BRA</wd:ID>
Currently I am trying to add this element and attribute - wd:Supplier_Invoice_Reference
<wd:ID wd:type=“Supplier_Invoice_Reference_ID”>1234</wd:ID>
</wd:Supplier_Invoice_Reference>
I am able to do this wd:Supplier_Invoice_Reference
<wd:ID type=“Supplier_Invoice_Reference_ID”>1234</wd:ID>
</wd:Supplier_Invoice_Reference>