473,508 Members | 2,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Namespace in XmlDocument

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="http://rep.oio.dk/ubl/xml/schemas/0p71/maindoc/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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:InvoiceCurrencyCode>
<com:BuyersReferenceID schemeID="EAN"></com:BuyersReferenceID>
<com:ReferencedOrder>
<com:BuyersOrderID></com:BuyersOrderID>
<com:IssueDate></com:IssueDate>
</com:ReferencedOrder>
<com:BuyerParty>
<com:ID schemeID="EAN"></com:ID>
<com:PartyName>
<com:Name></com:Name>
</com:PartyName>
<com:Address>
<com:ID></com:ID>
<com:Street></com:Street>
<com:HouseNumber></com:HouseNumber>
<com:CityName></com:CityName>
<com:PostalZone></com:PostalZone>
<com:Country>
<com:Code></com:Code>
</com:Country>
</com:Address>
<com:BuyerContact>
<com:ID></com:ID>
</com:BuyerContact>
</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:IssueDate xmlns:com="test">200500001</com:IssueDate>
<com:TypeCode xmlns:com="test">PIE</com:TypeCode>
<main:InvoiceCurrencyCode
xmlns:main="test">DKK</main:InvoiceCurrencyCode>
<com:BuyersReferenceID com:schemeID="EAN"
xmlns:com="test">10000000</com:BuyersReferenceID>
<com:ReferencedOrder xmlns:com="test">
<com:BuyersOrderID>039090</com:BuyersOrderID>
<com:IssueDate>2005-02-14</com:IssueDate>
</com:ReferencedOrder>
<com:BuyerParty xmlns:com="test">
<com:ID com:schemeID="EAN">28147317</com:ID>
<com:PartyName>
<com:Name>JG Company</com:Name>
</com:PartyName>
<com:BuyerContact>
<com:ID>te**@test.com</com:ID>
<com:ID>te***@test.com</com:ID>
</com:BuyerContact>
</com:BuyerParty>
<com:SellerParty xmlns:com="test">
<com:ID com:schemeID="CVR">23568978</com:ID>
<com:PartyName>
<com:Name>Bygma</com:Name>
</com:PartyName>
<com:Address>
<com:ID>Vareafsendelse</com:ID>
<com:Street>Hovedgaden</com:Street>
<com:HouseNumber>30</com:HouseNumber>
<com:CityName>Copenhagen</com:CityName>
<com:PostalZone>3000</com:PostalZone>
</com:Address>
<com:PartyTaxScheme>
<com:CompanyTaxID com:schemeID="CVR">23568978</com:CompanyTaxID>
</com:PartyTaxScheme>
</com:SellerParty>
</Invoice>

I start my document like this:

XmlDocument doc = new XmlDocument();
XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "iso-8859-1",
null);
XmlElement root = doc.DocumentElement;
doc.InsertBefore(decl, root);
XmlElement HeadElement = doc.CreateElement(null, "Invoice", "test");
doc.AppendChild(HeadElement);

And continue to add elements like this:

//<com:Address>
XmlElement node_addr = doc.CreateElement("com", "Address", "test");

//<com:ID>Vareafsendelse</com:ID>
XmlElement e_addr_id = doc.CreateElement("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!
Nov 16 '05 #1
0 1749

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2958
by: Izvra | last post by:
How can i specify default XML namespace when it does not declared in the xml document I need it for validation against xml schema @@@I have a procedure Sub ValidateXMLDocument(ByRef XMLDocument...
5
13573
by: jrmsmo | last post by:
Hi I have a document as follows: <?xml version="1.0"?> <metadata xml:lang="en"> </metadata> I want to change the document so it looks as follows: <?xml version="1.0"?> <metadata...
2
2269
by: Matt Torline via .NET 247 | last post by:
I am trying to duplicate an xml document, and I am pretty new to xml. I am using hte Xml namespace and taking advantage of the xmldocument class. I would like to add the following to an element ...
2
11395
by: Manoj G | last post by:
Hello, I believe there is no way to remove the default namespace declaration (For eg <DataSet xmlns="something">.... ) on an XmlNode object directly through DOM. So, what is the best way to...
3
3467
by: JT | last post by:
Hi all, I have a pretty basic question... I have a method (below) which uses ExecuteXMLReader to load the output from a FOR XML Explicit stored procedure into an XML document, and then save the...
4
4162
by: David Grogan | last post by:
Hi, 2 questions.... 1. I'm parsing an XHTML document that contains both the default namespace (xmlns="http://www.w3.org/1999/xhtml") and a custom one (xmlns:r="...") - both of these being...
2
7230
by: Christoph | last post by:
I'm using the following code to create what will be the root element of my XML document. XmlDocument controlDocument = new XmlDocument(); //add root node XmlElement rootNode =...
3
27035
by: Andy Fish | last post by:
Hi, I am creating a new XmlDocument from scratch, but I can't see how I can make a namespace declaration and associate a prefix with it. For instance in the following example: XmlDocument doc...
0
5960
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku...
4
4125
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku...
0
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.