473,383 Members | 1,862 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,383 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 3410
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.