I have an XML File where i want to change the Attribute "subtype" in all the nodes with name "Product" to some other value. But somehow i seem to have problems with the select node part.
My XML looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!-- GENERATED BY: PLM XML SDK 7.0.4.411 -->
<PLMXML xmlns="http://www.plmxml.org/Schemas/PLMXMLSchema" language="en-us"
time="16:26:35" schemaVersion="6" author="Teamcenter
V10000.1.0.70_20161101.00 - infodba@PESYS(1470348095)" date="2018-09-25">
<Product id="id35" name="78033031000" subType="Item" accessRefs="#id10"
productId="78033031000">
<Description>78033031000</Description>
<ApplicationRef application="Teamcenter" label="JfYtyiXp1pzuzD"
version="JfYtyiXp1pzuzD"></ApplicationRef>
</Product>
<Product id="id66" name="0405222613" subType="Item" accessRefs="#id10"
productId="0405222613">
<Description>0405222613</Description>
<ApplicationRef application="Teamcenter" label="yCdhv99n1pzuzD"
version="yCdhv99n1pzuzD"></ApplicationRef>
</Product>
<Product id="id90" name="59033080000" subType="Item" accessRefs="#id10"
productId="59033080000">
<Description>59033080000</Description>
<ApplicationRef application="Teamcenter" label="0OShlqVN1pzuzD"
version="0OShlqVN1pzuzD"></ApplicationRef>
</Product>
</PLMXML>
So my intuitive try looks like this:
'Load the XML file in XmlDocument.
Dim doc As New XmlDocument()
doc.Load("C:\export\79533500000.xml")
'Fetch the specific Nodes by Name.
Dim nodeList As XmlNodeList = doc.SelectNodes("/PLMXML/Product")
'Loop through the selected Nodes.
For Each node As XmlNode In nodeList
'Fetch the Node and Attribute values.
node("Product").SetAttribute("subType", "Product_Value12")
Next
doc.Save("C:\export\test_new.xml")
End Sub
This actually does nothing so i tried to change doc.SelectNodes("/PLMXML/Product") to doc.SelectNodes("*") which does an attribute change for "subtype" but only for the first "Product" node.
Could you please help me an tell me what i am doing wrong here?
Thanks & Greets Bernhard