Hi there
I have a small problem with my namespaces:
I would like to end up with this xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Invoice xmlns="http://rep.oio.dk/ubl/xml/schemas/0p71/pip/"
xmlns:com="http ://rep.oio.dk/ubl/xml/schemas/0p71/common/"
xmlns:main="htt p://rep.oio.dk/ubl/xml/schemas/0p71/maindoc/"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://rep.oio.dk/ubl/xml/schemas/0p71/pip/
http://rep.oio.dk/ubl/xml/schemas/0p71/pip/piplax.xsd">
<com:ID></com:ID>
<com:IssueDate> </com:IssueDate>
<com:TypeCode ></com:TypeCode>
<main:InvoiceCu rrencyCode>
<com:BuyersRefe renceID schemeID="EAN"> </com:BuyersRefer enceID>
<com:Referenced Order>
<com:BuyersOrde rID></com:BuyersOrder ID>
<com:IssueDate> </com:IssueDate>
</com:ReferencedO rder>
<com:BuyerParty >
<com:ID schemeID="EAN"> </com:ID>
<com:PartyNam e>
<com:Name></com:Name>
</com:PartyName>
<com:Address>
<com:ID></com:ID>
<com:Street></com:Street>
<com:HouseNumbe r></com:HouseNumber >
<com:CityName ></com:CityName>
<com:PostalZone ></com:PostalZone>
<com:Country>
<com:Code></com:Code>
</com:Country>
</com:Address>
<com:BuyerConta ct>
<com:ID></com:ID>
</com:BuyerContac t>
</com:BuyerParty>
</Invoice>
But I end up with this
(i have substituttet my namespaces with "test" otherwise the document
gets so long)
<?xml version="1.0" encoding="iso-8859-1"?>
<Invoice xmlns="test">
<com:ID xmlns:com="test ">2000</com:ID>
<com:IssueDat e xmlns:com="test ">200500001 </com:IssueDate>
<com:TypeCode xmlns:com="test ">PIE</com:TypeCode>
<main:InvoiceCu rrencyCode
xmlns:main="tes t">DKK</main:InvoiceCur rencyCode>
<com:BuyersRefe renceID com:schemeID="E AN"
xmlns:com="test ">10000000</com:BuyersRefer enceID>
<com:Referenced Order xmlns:com="test ">
<com:BuyersOrde rID>039090</com:BuyersOrder ID>
<com:IssueDate> 2005-02-14</com:IssueDate>
</com:ReferencedO rder>
<com:BuyerPar ty xmlns:com="test ">
<com:ID com:schemeID="E AN">28147317</com:ID>
<com:PartyNam e>
<com:Name>JG Company</com:Name>
</com:PartyName>
<com:BuyerConta ct>
<com:ID>te**@te st.com</com:ID>
<com:ID>te***@t est.com</com:ID>
</com:BuyerContac t>
</com:BuyerParty>
<com:SellerPart y xmlns:com="test ">
<com:ID com:schemeID="C VR">23568978</com:ID>
<com:PartyNam e>
<com:Name>Bygma </com:Name>
</com:PartyName>
<com:Address>
<com:ID>Vareafs endelse</com:ID>
<com:Street>Hov edgaden</com:Street>
<com:HouseNumbe r>30</com:HouseNumber >
<com:CityName>C openhagen</com:CityName>
<com:PostalZone >3000</com:PostalZone>
</com:Address>
<com:PartyTaxSc heme>
<com:CompanyTax ID com:schemeID="C VR">23568978</com:CompanyTaxI D>
</com:PartyTaxSch eme>
</com:SellerParty >
</Invoice>
I start my document like this:
XmlDocument doc = new XmlDocument();
XmlDeclaration decl = doc.CreateXmlDe claration("1.0" , "iso-8859-1",
null);
XmlElement root = doc.DocumentEle ment;
doc.InsertBefor e(decl, root);
XmlElement HeadElement = doc.CreateEleme nt(null, "Invoice", "test");
doc.AppendChild (HeadElement);
And continue to add elements like this:
//<com:Address>
XmlElement node_addr = doc.CreateEleme nt("com", "Address", "test");
//<com:ID>Vareafs endelse</com:ID>
XmlElement e_addr_id = doc.CreateEleme nt("com", "ID", "test");
Can anyone help to solve this ? :-)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!