473,395 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Creating a XML file containing nodes with namespaces

I'm having the following problem

I want to create a XML document like

<?xml version="1.0" encoding="utf-8"?>
<RedlineXML
xmlns="urn:autodesk.com:dsd:RedlineXML_v_002.xdr"
xmlns:redline="urn:autodesk.com:dsd:RedlineXML_v_0 02.xdr">
<redline:RedlineMarkup>
<redline:MarkupPlanes>
<redline:MarkupPlane name="Model" />
</redline:MarkupPlanes>
</redline:RedlineMarkup>
</RedlineXML>

I've managed to create something like

<RedlineXML>
<RedlineMarkup>
<MarkupPlanes>
<MarkupPlane name="MyName"/>
</MarkupPlanes>
</RedlineMarkup>
</RedlineXML>

But I'm missing the part of the namespaces

I don't know how to add the namespace to each of the nodes

<redline:Tags>
This is the relevant part of the code I have so far......

XmlDocument doc = new XmlDocument();
XmlElement rootNode = doc.CreateElement( "RedlineXML" ) ;

doc.AppendChild( rootNode );

XmlElement markupNode = doc.CreateElement(
"RedlineMarkup" ) ;
rootNode.AppendChild( markupNode );

// Rest of code

doc.Save( "Redline.xml" );

Thanks in advance

Tincho
Nov 12 '05 #1
2 3411
CreateElement has overloads that accept prefix, localname and namespaceURI.

try something like below ... though you might not be able to get the exact
same text output you should be able to preserve the semantics.

XmlElement rootNode = doc.CreateElement("", "RedlineXML",
"urn:autodesk.com:dsd:RedlineXML_v_002.xdr");

XmlElement childNode = doc.CreateElement("redline","RedlineMarkup",
"urn:autodesk.com:dsd:RedlineXML_v_002.xdr");

XmlElement grandChild = doc.CreateElement("redline:MarkupPlanes");

childNode.AppendChild(grandChild);
rootNode.AppendChild(childNode);
doc.Append(rootNode);
--
This posting is provided "AS IS" with no warranties, and confers no rights.

"ro*********@gmx.net" <an*******@discussions.microsoft.com> wrote in message
news:1a*****************************@phx.gbl...
I'm having the following problem

I want to create a XML document like

<?xml version="1.0" encoding="utf-8"?>
<RedlineXML
xmlns="urn:autodesk.com:dsd:RedlineXML_v_002.xdr"
xmlns:redline="urn:autodesk.com:dsd:RedlineXML_v_0 02.xdr">
<redline:RedlineMarkup>
<redline:MarkupPlanes>
<redline:MarkupPlane name="Model" />
</redline:MarkupPlanes>
</redline:RedlineMarkup>
</RedlineXML>

I've managed to create something like

<RedlineXML>
<RedlineMarkup>
<MarkupPlanes>
<MarkupPlane name="MyName"/>
</MarkupPlanes>
</RedlineMarkup>
</RedlineXML>

But I'm missing the part of the namespaces

I don't know how to add the namespace to each of the nodes

<redline:Tags>
This is the relevant part of the code I have so far......

XmlDocument doc = new XmlDocument();
XmlElement rootNode = doc.CreateElement( "RedlineXML" ) ;

doc.AppendChild( rootNode );

XmlElement markupNode = doc.CreateElement(
"RedlineMarkup" ) ;
rootNode.AppendChild( markupNode );

// Rest of code

doc.Save( "Redline.xml" );

Thanks in advance

Tincho

Nov 12 '05 #2
CreateElement has overloads that accept prefix, localname and namespaceURI.

try something like below ... though you might not be able to get the exact
same text output you should be able to preserve the semantics.

XmlElement rootNode = doc.CreateElement("", "RedlineXML",
"urn:autodesk.com:dsd:RedlineXML_v_002.xdr");

XmlElement childNode = doc.CreateElement("redline","RedlineMarkup",
"urn:autodesk.com:dsd:RedlineXML_v_002.xdr");

XmlElement grandChild = doc.CreateElement("redline:MarkupPlanes");

childNode.AppendChild(grandChild);
rootNode.AppendChild(childNode);
doc.Append(rootNode);
--
This posting is provided "AS IS" with no warranties, and confers no rights.

"ro*********@gmx.net" <an*******@discussions.microsoft.com> wrote in message
news:1a*****************************@phx.gbl...
I'm having the following problem

I want to create a XML document like

<?xml version="1.0" encoding="utf-8"?>
<RedlineXML
xmlns="urn:autodesk.com:dsd:RedlineXML_v_002.xdr"
xmlns:redline="urn:autodesk.com:dsd:RedlineXML_v_0 02.xdr">
<redline:RedlineMarkup>
<redline:MarkupPlanes>
<redline:MarkupPlane name="Model" />
</redline:MarkupPlanes>
</redline:RedlineMarkup>
</RedlineXML>

I've managed to create something like

<RedlineXML>
<RedlineMarkup>
<MarkupPlanes>
<MarkupPlane name="MyName"/>
</MarkupPlanes>
</RedlineMarkup>
</RedlineXML>

But I'm missing the part of the namespaces

I don't know how to add the namespace to each of the nodes

<redline:Tags>
This is the relevant part of the code I have so far......

XmlDocument doc = new XmlDocument();
XmlElement rootNode = doc.CreateElement( "RedlineXML" ) ;

doc.AppendChild( rootNode );

XmlElement markupNode = doc.CreateElement(
"RedlineMarkup" ) ;
rootNode.AppendChild( markupNode );

// Rest of code

doc.Save( "Redline.xml" );

Thanks in advance

Tincho

Nov 12 '05 #3

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

Similar topics

3
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
2
by: Maersa | last post by:
hi, i'm trying to add "attributes" to some nodes and it works at design time but fails at runtime. XmlDocument doc = new XmlDocument(); XmlElement elem = doc.CreateElement( "root" );...
0
by: robin_hoods | last post by:
I'm having the following problem I want to create a XML document like <?xml version="1.0" encoding="utf-8"?> <RedlineXML xmlns="urn:autodesk.com:dsd:RedlineXML_v_002.xdr"...
2
by: David Elliott | last post by:
I am creating a configuration class to read / write a standard configuration file. <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="ConnectionString"...
8
by: Martin Eyles | last post by:
Hi, I have a configuration file I made in xml which I am using to name a database server. (this way I can deploy my web page on various servers, and just change this file to make it work)....
8
by: Simon Edwards | last post by:
Something thats been bugging me for a while... how do you create a namespace that has many children (namespaces) I.e system.io.blah.blah Iv'e done it by creating a class which contains...
8
by: Alan Silver | last post by:
Hello, I have a need to read the web.config file from another web site. I am trying get the value of the "theme" attribute of the "pages" node. I initially tried to do this by loading the file...
1
by: Peter Bradley | last post by:
Hi, I'm trying to create an XML Document. This is what I want to end up with: <pre> <?xml version="1.0" encoding="UTF-8" ?> <epp xmlns="urn:iana:xml:ns:epp-1.0"...
7
by: Peter Bradley | last post by:
Hi, First of all, a confession. This is a cross post from the microsoft.public.dotnet.general list. I posted there not realising that this list existed. Apologies to those who read both...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.