472,955 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,955 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 8066


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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.