473,586 Members | 2,682 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="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!
Nov 16 '05 #1
0 1758

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

Similar topics

1
2963
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 As Xml.XmlDocument, ByVal SchemaPath as string) If XMLDocument.DocumentElement.NamespaceURI = String.Empty Then '@@@ calculating target namspace...
5
13574
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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://localhost/XMLDemo/MyXMLschema.xsd">
2
2276
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 xmlns:dt="urn:schemas-microsoft-com:datatypes" Is there a way to do this through the setattribute or createelement methods? Whenever I try all i...
2
11401
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 remove it 1) XSLT templates? 2) Copy all the contents into a new node and leave out the namespace? Use this node node in lieu of the old one?
3
3474
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 document to a file. It works well. Now, I am trying to add namespace support, and want my namespace to be something like "http://MapTo837P". How do...
4
4173
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 attributes of <html>. When I then insert new XmlNodes into the DOM the HTML tags all end up getting an unnecesarry 'xmlns' attribute added, elements with...
2
7241
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 = controlDocument.CreateElement( "ns0:MyRootElement" ); rootNode.SetAttribute( "xmlns:ns0", "http://my.namespace.uri" ); controlDocument.AppendChild(rootNode); I'm...
3
27047
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 = new XmlDocument(); XmlElement el = doc.CreateElement("foo:data"); doc.AppendChild(el); doc.Save("foo.xml");
0
5962
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 in advance When I run the pgm , I get the error: Can't parse login information. Namespace Manager or XsltContext needed. This query has a...
4
4132
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 in advance When I run the pgm , I get the error: Can't parse login information. Namespace Manager or XsltContext needed. This query has a...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8216
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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 we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.