Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 10th, 2006, 03:25 PM
bhu
Guest
 
Posts: n/a
Default Xml document Node with Multiple NameSpace

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




  #2  
Old August 10th, 2006, 04:05 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: Xml document Node with Multiple NameSpace



bhu wrote:

Quote:
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">
Quote:
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/
  #3  
Old August 10th, 2006, 05:15 PM
bhu
Guest
 
Posts: n/a
Default Re: Xml document Node with Multiple NameSpace

Cool This worked.
Thank you.
bhu.

"Martin Honnen" <mahotrash@yahoo.dewrote in message
news:%23SieL8IvGHA.3364@TK2MSFTNGP02.phx.gbl...
Quote:
>
>
bhu wrote:
>
>
Quote:
>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">
>
>
Quote:
>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/

  #4  
Old August 11th, 2006, 02:45 PM
bhu
Guest
 
Posts: n/a
Default Re: Xml document Node with Multiple NameSpace

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" <mahotrash@yahoo.dewrote in message
news:%23SieL8IvGHA.3364@TK2MSFTNGP02.phx.gbl...
Quote:
>
>
bhu wrote:
>
>
Quote:
>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">
>
>
Quote:
>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/

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles