473,385 Members | 1,919 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,385 software developers and data experts.

Xml document Node with Multiple NameSpace

bhu
Hi
i am trying some things in XML for webservices but got stuck with the xml
Creation.
This is the First Sample
C# Code
XmlDocument oInvDocument = new XmlDocument();
oNode=
oInvDocument.CreateNode(XmlNodeType.Element,"Inven toryUpdateBatch","");
oInvDocument.AppendChild(oNode);

output >>>>
<iu:InventoryUpdateBatch
xmlns:iu="http://www.abc.com/integrations/schema/InventoryUpdate"
xmlns:th="http://www.abc.com/integrations/schema/TransactionHeader"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\InventoryUpdate.xsd">
<InventoryUpdate>
<TransactionHeader>
..........................

1.how to add multiple NameSpace to the XML, the code above will add only
the Element, i don;t know to add the ns?
2. Let us say i have a DataSet which is named "InventoryUpdateBatch" and
has table InventoryUpdate and TransactionHeader when i saveas xml i get the
xml but i want
with namespace ? and also some of the element let us say should come with
": " <th:Client_IDsome thing like this, if i say the table name to be
th:client_Id i get the xml as
<th_x00A_Client_ID>.

any ideas please ?
Thanks
bhu


Aug 10 '06 #1
3 8100


bhu wrote:

output >>>>
<iu:InventoryUpdateBatch
xmlns:iu="http://www.abc.com/integrations/schema/InventoryUpdate"
xmlns:th="http://www.abc.com/integrations/schema/TransactionHeader"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\InventoryUpdate.xsd">
1.how to add multiple NameSpace to the XML, the code above will add only
the Element, i don;t know to add the ns?
Here is an example:

const string iu =
"http://www.abc.com/integrations/schema/InventoryUpdate", th =
"http://www.abc.com/integrations/schema/TransactionHeader", xmlns =
"http://www.w3.org/2000/xmlns/", xsi =
"http://www.w3.org/2001/XMLSchema-instance";

XmlDocument xmlDocument = new XmlDocument();
XmlElement inventoryUpdateBatch = xmlDocument.CreateElement("iu",
"InventoryUpdateBatch", iu);

XmlAttribute thNamespace = xmlDocument.CreateAttribute("xmlns:th",
xmlns);
thNamespace.Value = th;
inventoryUpdateBatch.SetAttributeNode(thNamespace) ;

XmlAttribute xsiNamespace =
xmlDocument.CreateAttribute("xmlns:xsi", xmlns);
xsiNamespace.Value = xsi;
inventoryUpdateBatch.SetAttributeNode(xsiNamespace );

inventoryUpdateBatch.SetAttribute("schemaLocation" , xsi,
@"http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\InventoryUpdate.xsd");

xmlDocument.AppendChild(inventoryUpdateBatch);

xmlDocument.Save("file.xml");

File will the be

<iu:InventoryUpdateBatch
xmlns:th="http://www.abc.com/integrations/schema/TransactionHeader"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\InventoryUpdate.xsd"
xmlns:iu="http://www.abc.com/integrations/schema/InventoryUpdate" />
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 10 '06 #2
bhu
Cool This worked.
Thank you.
bhu.

"Martin Honnen" <ma*******@yahoo.dewrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>

bhu wrote:

>output >>>>
<iu:InventoryUpdateBatch
xmlns:iu="http://www.abc.com/integrations/schema/InventoryUpdate"
xmlns:th="http://www.abc.com/integrations/schema/TransactionHeader"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\InventoryUpdate.xsd">

>1.how to add multiple NameSpace to the XML, the code above will add only
the Element, i don;t know to add the ns?

Here is an example:

const string iu =
"http://www.abc.com/integrations/schema/InventoryUpdate", th =
"http://www.abc.com/integrations/schema/TransactionHeader", xmlns =
"http://www.w3.org/2000/xmlns/", xsi =
"http://www.w3.org/2001/XMLSchema-instance";

XmlDocument xmlDocument = new XmlDocument();
XmlElement inventoryUpdateBatch = xmlDocument.CreateElement("iu",
"InventoryUpdateBatch", iu);

XmlAttribute thNamespace = xmlDocument.CreateAttribute("xmlns:th",
xmlns);
thNamespace.Value = th;
inventoryUpdateBatch.SetAttributeNode(thNamespace) ;

XmlAttribute xsiNamespace = xmlDocument.CreateAttribute("xmlns:xsi",
xmlns);
xsiNamespace.Value = xsi;
inventoryUpdateBatch.SetAttributeNode(xsiNamespace );

inventoryUpdateBatch.SetAttribute("schemaLocation" , xsi,
@"http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\InventoryUpdate.xsd");

xmlDocument.AppendChild(inventoryUpdateBatch);

xmlDocument.Save("file.xml");

File will the be

<iu:InventoryUpdateBatch
xmlns:th="http://www.abc.com/integrations/schema/TransactionHeader"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\InventoryUpdate.xsd"
xmlns:iu="http://www.abc.com/integrations/schema/InventoryUpdate" />
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Aug 10 '06 #3
bhu
Thanks Martin for the answer.
any idea about the 2nd Question ?, i want to ask that question as a new
subject, before i do i thought i will ask.
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>

bhu wrote:

>output >>>>
<iu:InventoryUpdateBatch
xmlns:iu="http://www.abc.com/integrations/schema/InventoryUpdate"
xmlns:th="http://www.abc.com/integrations/schema/TransactionHeader"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\InventoryUpdate.xsd">

>1.how to add multiple NameSpace to the XML, the code above will add only
the Element, i don;t know to add the ns?

Here is an example:

const string iu =
"http://www.abc.com/integrations/schema/InventoryUpdate", th =
"http://www.abc.com/integrations/schema/TransactionHeader", xmlns =
"http://www.w3.org/2000/xmlns/", xsi =
"http://www.w3.org/2001/XMLSchema-instance";

XmlDocument xmlDocument = new XmlDocument();
XmlElement inventoryUpdateBatch = xmlDocument.CreateElement("iu",
"InventoryUpdateBatch", iu);

XmlAttribute thNamespace = xmlDocument.CreateAttribute("xmlns:th",
xmlns);
thNamespace.Value = th;
inventoryUpdateBatch.SetAttributeNode(thNamespace) ;

XmlAttribute xsiNamespace = xmlDocument.CreateAttribute("xmlns:xsi",
xmlns);
xsiNamespace.Value = xsi;
inventoryUpdateBatch.SetAttributeNode(xsiNamespace );

inventoryUpdateBatch.SetAttribute("schemaLocation" , xsi,
@"http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\InventoryUpdate.xsd");

xmlDocument.AppendChild(inventoryUpdateBatch);

xmlDocument.Save("file.xml");

File will the be

<iu:InventoryUpdateBatch
xmlns:th="http://www.abc.com/integrations/schema/TransactionHeader"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\InventoryUpdate.xsd"
xmlns:iu="http://www.abc.com/integrations/schema/InventoryUpdate" />
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Aug 11 '06 #4

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

Similar topics

0
by: David Gersic | last post by:
I'm working with an HR system and trying to deal with an XML document that contains a bunch of personal data (unique to the person) and one or more sets of job data (a person can be hired more than...
1
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...
1
by: Seong-Tae Jeong | last post by:
for example, xml document is below, It has a default namespace "xmlns='qwer://test'". string xmlText = "<test xmlns='http://test'><clear/><clear/></test>"; I would like to select node list...
2
by: shawnk | last post by:
I've been writing an XML document analyzer that reads XML document and tracks the metrics of the document. Statistics such as a node count fo each type of XML node are printed out I am trying to...
0
by: Martin | last post by:
Hi, I would appreciate some help with creating an xml node in a document and automatically setting the default namespace The code below loads an xmnldocument with a default namespace --...
5
by: anupamjain | last post by:
Tired, Exhausted, searched the web, usenets,forums thorughly but still clueless. I guess it's time to post on the group : This is the issue I have been trying to resolve since today morning : ...
5
by: Norsoft | last post by:
How can I convert an existing schema to an xml document. I have a series of schema documents that validate xml documents that describe metadata. Normally the metadata is first defined in a database,...
2
by: Andy | last post by:
Hi, I have an XML document that uses namespaces (it is from a Word 2007 file). I want to retrieve all the "t" elements that belong to the "w" namespace (<w:t>) using XPath from VB.NET 2003 (.NET...
2
by: nicky123 | last post by:
Hi everyone, This is a brief description that I have provided for parsing & displaying an XML document using DOM API. Please feel free to post your own comments & views regarding...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
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...

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.