Results 1 to 22 of 22

Thread: Need help building an XML document

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Need help building an XML document

    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:

    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 first need to fill in the <Name> node with a value. Then I want to define a sub-node as follows:

    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>"
    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.
    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...
    Attached Files Attached Files
    Last edited by nbrege; Jul 17th, 2023 at 03:58 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width