Avatar of spen_lang
spen_lang

asked on 

VB NET XML

Hi,

I have been asked to add the following line to my XML file by our customer but I am unsure how to or what exactly it is? I know one part is referencing a namespace...

<ns0:IMG_DOCUMENT xmlns:ns0="urn://nagelgroup.com">

The XML document currently looks like this:

<?xml version="1.0" encoding="utf-8"?>
<DocumentProcessorGroups>
<group>
  <PageCount>1</PageCount>
  <FileCount>1</FileCount>
  <FileName>C:\12345</FileName>
  <Barcode>1223458421</Barcode>
</group>
<Variables>
  <NUMMER></NUMMER>
  <DATUM></DATUM>
  <KUNDENNR></KUNDENNR>
  <KUNDENNAME></KUNDENNAME>
  <BUKREIS></BUKREIS>
</Variables>
</DocumentProcessorGroups>


But need to look like this:
<?xml version="1.0" encoding="utf-8"?><ns0:IMG_DOCUMENT xmlns:ns0="urn://nagelgroup.com">
<DocumentProcessorGroups>
<group>
  <PageCount>1</PageCount>
  <FileCount>1</FileCount>
  <FileName>C:\12345</FileName>
  <Barcode>1223458421</Barcode>
</group>
<Variables>
  <NUMMER></NUMMER>
  <DATUM></DATUM>
  <KUNDENNR></KUNDENNR>
  <KUNDENNAME></KUNDENNAME>
  <BUKREIS></BUKREIS>
</Variables>
</DocumentProcessorGroups>

My current code is:

Dim xml As XDocument = New XDocument(
                    New XDeclaration("1.0", "UTF-8", String.Empty),
                    New XCData("ns0:IMG_DOCUMENT xmlns:ns0=""urn://nagelgroup.com"""),
                    New XElement("DocumentProcessorGroups",
                        New XElement("group",
                            New XElement("PageCount", sPageCount),
                            New XElement("FileCount", "1"),
                            New XElement("FileName", Path.GetFileNameWithoutExtension(sTargetPDFFullFilename)),
                            New XElement("Barcode", sBarcode)),
                                New XElement("Variables",
                                New XElement("NUMMER", sNummer),
                                New XElement("DATUM", sDatum),
                                New XElement("KUNDENNR", sKundenNr),
                                New XElement("KUNDENNAME", sKundenName),
                                New XElement("BUKREIS", sBukreis))))

Open in new window


Please help thanks, Greg
Visual Basic.NETVB ScriptXML

Avatar of undefined
Last Comment
Fernando Soto

8/22/2022 - Mon