avoid extra xmlns:xsi while adding a attribute to xml root element in C#.net
Posted
by Rakesh kumar
on Stack Overflow
See other posts from Stack Overflow
or by Rakesh kumar
Published on 2010-06-18T12:39:22Z
Indexed on
2010/06/18
12:43 UTC
Read the original article
Hit count: 258
c#
Please help me. First pls forgive me if i am wrong.
i am createing a xmlfile using c#.net . my Code is like
XmlDocument d = new XmlDocument(); XmlDeclaration xmlDeclaration = d.CreateXmlDeclaration("1.0", "utf-8", null); d.InsertBefore(xmlDeclaration,d.DocumentElement); XmlElement root = d.CreateElement("ITRETURN","ITR","http://incometaxindiaefiling.gov.in/ITR1"); XmlAttribute xsiNs = d.CreateAttribute("xsi:schemaLocation", "http://www.w3.org/2001/XMLSchema-instance"); xsiNs.Value = "http://incometaxindiaefiling.gov.in/main ITRMain10.xsd"; root.SetAttributeNode(xsiNs); //root.SetAttribute("xsi:schemaLocation", "http://www.w3.org/2001/XMLSchema-instance"); root.SetAttribute("xmlns:ITR1FORM", "http://incometaxindiaefiling.gov.in/ITR1"); root.SetAttribute("xmlns:ITR2FORM", "http://incometaxindiaefiling.gov.in/ITR2"); root.SetAttribute("xmlns:ITR3FORM", "http://incometaxindiaefiling.gov.in/ITR3"); root.SetAttribute("xmlns:ITR4FORM", "http://incometaxindiaefiling.gov.in/ITR4"); d.AppendChild(root); d.Save("c://myxml.xml");
and i am getting output like this
- - root node
But My requirement is like
+ any value
please help
© Stack Overflow or respective owner