473,762 Members | 8,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Cr eateNode(XmlNod eType.Element," InventoryUpdate Batch","");
oInvDocument.Ap pendChild(oNode );

output >>>>
<iu:InventoryUp dateBatch
xmlns:iu="http://www.abc.com/integrations/schema/InventoryUpdate "
xmlns:th="http://www.abc.com/integrations/schema/TransactionHead er"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\ InventoryUpdate .xsd">
<InventoryUpdat e>
<TransactionHea der>
............... ...........

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 "InventoryUpdat eBatch" and
has table InventoryUpdate and TransactionHead er 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_IDso me 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 8128


bhu wrote:

output >>>>
<iu:InventoryUp dateBatch
xmlns:iu="http://www.abc.com/integrations/schema/InventoryUpdate "
xmlns:th="http://www.abc.com/integrations/schema/TransactionHead er"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="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/TransactionHead er", xmlns =
"http://www.w3.org/2000/xmlns/", xsi =
"http://www.w3.org/2001/XMLSchema-instance";

XmlDocument xmlDocument = new XmlDocument();
XmlElement inventoryUpdate Batch = xmlDocument.Cre ateElement("iu" ,
"InventoryUpdat eBatch", iu);

XmlAttribute thNamespace = xmlDocument.Cre ateAttribute("x mlns:th",
xmlns);
thNamespace.Val ue = th;
inventoryUpdate Batch.SetAttrib uteNode(thNames pace);

XmlAttribute xsiNamespace =
xmlDocument.Cre ateAttribute("x mlns:xsi", xmlns);
xsiNamespace.Va lue = xsi;
inventoryUpdate Batch.SetAttrib uteNode(xsiName space);

inventoryUpdate Batch.SetAttrib ute("schemaLoca tion", xsi,
@"http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\ InventoryUpdate .xsd");

xmlDocument.App endChild(invent oryUpdateBatch) ;

xmlDocument.Sav e("file.xml") ;

File will the be

<iu:InventoryUp dateBatch
xmlns:th="http://www.abc.com/integrations/schema/TransactionHead er"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="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*******@yaho o.dewrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>

bhu wrote:

>output >>>>
<iu:InventoryU pdateBatch
xmlns:iu="http ://www.abc.com/integrations/schema/InventoryUpdate "
xmlns:th="http ://www.abc.com/integrations/schema/TransactionHead er"
xmlns:xsi="htt p://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLoca tion="http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd \InventoryUpdat e.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/TransactionHead er", xmlns =
"http://www.w3.org/2000/xmlns/", xsi =
"http://www.w3.org/2001/XMLSchema-instance";

XmlDocument xmlDocument = new XmlDocument();
XmlElement inventoryUpdate Batch = xmlDocument.Cre ateElement("iu" ,
"InventoryUpdat eBatch", iu);

XmlAttribute thNamespace = xmlDocument.Cre ateAttribute("x mlns:th",
xmlns);
thNamespace.Val ue = th;
inventoryUpdate Batch.SetAttrib uteNode(thNames pace);

XmlAttribute xsiNamespace = xmlDocument.Cre ateAttribute("x mlns:xsi",
xmlns);
xsiNamespace.Va lue = xsi;
inventoryUpdate Batch.SetAttrib uteNode(xsiName space);

inventoryUpdate Batch.SetAttrib ute("schemaLoca tion", xsi,
@"http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\ InventoryUpdate .xsd");

xmlDocument.App endChild(invent oryUpdateBatch) ;

xmlDocument.Sav e("file.xml") ;

File will the be

<iu:InventoryUp dateBatch
xmlns:th="http://www.abc.com/integrations/schema/TransactionHead er"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="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*******@yaho o.dewrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>

bhu wrote:

>output >>>>
<iu:InventoryU pdateBatch
xmlns:iu="http ://www.abc.com/integrations/schema/InventoryUpdate "
xmlns:th="http ://www.abc.com/integrations/schema/TransactionHead er"
xmlns:xsi="htt p://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLoca tion="http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd \InventoryUpdat e.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/TransactionHead er", xmlns =
"http://www.w3.org/2000/xmlns/", xsi =
"http://www.w3.org/2001/XMLSchema-instance";

XmlDocument xmlDocument = new XmlDocument();
XmlElement inventoryUpdate Batch = xmlDocument.Cre ateElement("iu" ,
"InventoryUpdat eBatch", iu);

XmlAttribute thNamespace = xmlDocument.Cre ateAttribute("x mlns:th",
xmlns);
thNamespace.Val ue = th;
inventoryUpdate Batch.SetAttrib uteNode(thNames pace);

XmlAttribute xsiNamespace = xmlDocument.Cre ateAttribute("x mlns:xsi",
xmlns);
xsiNamespace.Va lue = xsi;
inventoryUpdate Batch.SetAttrib uteNode(xsiName space);

inventoryUpdate Batch.SetAttrib ute("schemaLoca tion", xsi,
@"http://www.abc.com/integrations/schema/InventoryUpdate
C:\Temp\ws\xsd\ InventoryUpdate .xsd");

xmlDocument.App endChild(invent oryUpdateBatch) ;

xmlDocument.Sav e("file.xml") ;

File will the be

<iu:InventoryUp dateBatch
xmlns:th="http://www.abc.com/integrations/schema/TransactionHead er"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="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
1201
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 once), all expressed in a single XML document. I want to flatten out the multiple job data parts by building a much larger XML document. (This may not make sense by itself, but it's part of a larger project.) Dummying up an example to...
1
2970
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 As Xml.XmlDocument, ByVal SchemaPath as string) If XMLDocument.DocumentElement.NamespaceURI = String.Empty Then '@@@ calculating target namspace of the schema
1
6854
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 "clear" with XPath Expression. XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml( xmlText );
2
1558
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 locate 'xmlns' nodes using the XPath (not DOM or SAX) API Unfortunately the XPathNavigator concept of namespace nodes for eac element is only accessible via MoveToFirstNamespace() an MoveToNextNamespace(). The XPath model constructs a namespace...
0
1030
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 -- xmlns=""http://mydomain.org/schema.xsd"" however when i create a nod in it below the node come out with a blank string set for the "xmlns" attribute.
5
9775
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 : I have an XHTML document in string form which I parse using Xerces DOMParser (using an InputSource to read it). Now I am trying to get to a node for which I have the Xpath, using the XPathAPI.
5
1766
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, then schemas generated from the database. In this case I was given the schemas and I am writing an application to create the database entries. I can't use a dataset as we have a very specific database structure. I started to load them into an...
2
7851
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 framework 1.1). I've successfully loaded the document into a XmlDocument DOM parser (I can dump the contents using OuterXML). And, I've created a XmlNamespaceManager and assigned it the "w" namespace.
2
2668
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 this discussion. Thank you. The first step of parsing an XML document is to import the DOM API related classes such as :- java.io.* which contains all the interfaces to perform an I/O operation. org.xml.sax.* which contains all the interfaces...
0
9554
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9378
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9989
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3914
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.