Last post Aug 26, 2009 12:58 PM by jagskadiyala
Aug 26, 2009 09:55 AM|jagskadiyala|LINK
I am converting xml to dataset and after doing some modifications in it, writing it back as xml using DataSet.WriteXml() method.
<ab:nodename xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ab.com/schemas/131 C:\Program Files\AB\RCT\abcd_Composite.xsd" xmlns:ab="http://www.ab.com/schemas/131" xmlns:ns1="http://ab.com/composite.xsd" xmlns:gml="http://www.opengis.net/gml"
But, while writing it back as xml this node written as:
and everthing else like xsi, gml, xlink declaration are discarded. I want to retain all of them as it was in the souce xml file.
Please tell me how can we retain those tags? Is there any property that needs to be set while calling WriteXML() method? Or is there any other way of doing the same?
Thanks and Regards...
Aug 26, 2009 11:54 AM|kavita_khandhadia|LINK
I think after to you receive the xml, you can append these attributes to it like this.
string xml = "<ab:nodename xmlns:ab='http://www.ab.com/schemas/131'/>";
XmlDocument xDoc = new XmlDocument();
if (xDoc.DocumentElement.Attributes.Count > 0)
XmlAttribute xAtt = xDoc.DocumentElement.Attributes;
XmlAttribute xAttNs = xDoc.CreateAttribute("xmlns:xsi");
xAttNs.Value = "http://www.w3.org/2001/XMLSchema-instance";
//Such as above, you can keep on adding the attributes you want.
//see your resul in following string.
string xmlDoc = xDoc.DocumentElement.OuterXml;
Aug 26, 2009 12:58 PM|jagskadiyala|LINK
Just now fixed it by same process....