I need to build an XML document from data read in from a csv file. I want to store the main body of the document in a string as follows:
I first need to fill in the <Name> node with a value. Then I want to define a sub-node as follows:Code:Dim mainNode As String = "<?xml version=""1.0"" encoding=""UTF-8""?> <Job> <ProductVersion>2022</ProductVersion> <Unit>mm</Unit> <Properties> <Job> <Information> <Job> <Name>Some Value</Name> <Description></Description> </Job> </Information> <Attributes> <Parameter> <Name>SI_UCS_Off</Name> <Description>++UCS's Off</Description> <Type>B</Type> <!--Measurement|Meas|M|Degrees|Deg|D|Integer|Int|I|Boolean|Bool|B|Decimal|Dec|D|Text|T|Currency|Cur|C--> <Value>1</Value> <Style>Note</Style> <!--Attribute|Note|Standard *standard is default if missing--> </Parameter> </Attributes> </Job> </Properties> <Rooms> ' insert sub-nodes here </Rooms> </Job>"
I need to set the <Name> node of this sub-node with a value, then insert the sub-node into the <Rooms> node of the main node.Code:Dim roomNode As String = " <Room> <RoomProperties> <Room> <General> <Name>Some Value</Name> </General> </Room> </RoomProperties> <Order> <Assemblies> ' insert sub-nodes here </Assemblies> </Order> </Room>"
Hopefully this makes sense. I'm not sure if I should use XmlDocument or XDocument. I'm hoping someone can help me get a start on this. I also need to add another sub-node under the <Assemblies> node, but if I can get help with the first part, I think I can figure it out. I haven't programmed in a few years so I'm a little rusty. Thanks...
***Edit: I attached a copy of what the full xml file needs to look like...




Reply With Quote
