Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

VB NET XML

Avatar of spen_lang
spen_lang asked on
XMLVisual Basic.NETVB Script
1 Comment1 Solution209 ViewsLast Modified:
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))))

Please help thanks, Greg
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answers