0

This is the child node that I want to add but if I use createElement method it includes xmlns attribute automatically but it doesn't required so give me some solution to add below node in xml .

<linkbase:schemaRef 
     xlink:type="simple" 
     xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase" 
     xlink:href="http://www.mca.gov.in/XBRL/2011/08/27/Taxonomy/CnI/ci/in-gaap-ci-2011-03-31.xsd">
</linkbase:schemaRef>

My program:

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Create the XmlDocument.
            XmlDocument XDoc = new XmlDocument();

            XmlDeclaration declaration = XDoc.CreateXmlDeclaration("1.0", "UTF-8", "");

            XmlElement XElemRoot = XDoc.CreateElement("xbrli", "xbrl", "http://www.xbrl.org/2003/instance" );
            XElemRoot.SetAttribute("xmlns:in-ca-types", "http://www.xbrl.org/in/2011-03-31/in-ca-types");
            XElemRoot.SetAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
            XElemRoot.SetAttribute("xmlns:net", "http://www.xbrl.org/2009/role/net" );
            XElemRoot.SetAttribute("xmlns:num", "http://www.xbrl.org/dtr/type/numeric" );
            XElemRoot.SetAttribute("xmlns:in-roles", "http://www.xbrl.org/in/2011-03-31/in-gaap-roles" );
            XElemRoot.SetAttribute("xmlns:link", "http://www.xbrl.org/2003/linkbase" );
            XElemRoot.SetAttribute("xmlns:negated", "http://www.xbrl.org/2009/role/negated");
            XElemRoot.SetAttribute("xmlns:iso4217", "http://www.xbrl.org/2003/iso4217" );
            XElemRoot.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
            XElemRoot.SetAttribute("xmlns:xbrldt","http://xbrl.org/2005/xbrldt"); 
            XElemRoot.SetAttribute("xmlns:in-gaap","http://www.xbrl.org/in/2011-03-31/in-gaap"); 
            XElemRoot.SetAttribute("xmlns:nonnum","http://www.xbrl.org/dtr/type/non-numeric" );
            XElemRoot.SetAttribute("xmlns:in-gaap-ci","http://www.xbrl.org/in/2011-03-31/in-gaap-ci" );
            XElemRoot.SetAttribute("xmlns:in-ca","http://www.xbrl.org/in/2011-03-31/in-ca" );
            XElemRoot.SetAttribute("xmlns:xhtml","http://www.w3.org/1999/xhtml" );
            XElemRoot.SetAttribute("xmlns:in-ca-roles", "http://www.xbrl.org/in/2011-03-31/in-ca-roles");

            XDoc.AppendChild(declaration);
            XDoc.AppendChild(comment);
            XDoc.AppendChild(XElemRoot);

            XDoc.Save(@"C:\XBRLDoc.xml");
        }
    }
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
pratik nagariya
  • 574
  • 5
  • 21

2 Answers2

0

You can use something like

xmlDoc.CreateElement("TesteElement", parentElem.NamespaceURI);

And this can help you, in other cases:

How to prevent blank xmlns attributes in output from .NET's XmlDocument?

Community
  • 1
  • 1
Lukinha RS
  • 410
  • 4
  • 12
0

this will create node like this

<linkbase:schemaRef type="simple" arcrole="http://www.w3.org/1999/xlink/properties/linkbase" href="http://www.mca.gov.in/XBRL/2011/08/27/Taxonomy/CnI/ci/in-gaap-ci-2011-03-31.xsd" xmlns:linkbase="http://www.xbrl.org/2003/instance" />

but i want to remove that xmlns attribute.

pratik nagariya
  • 574
  • 5
  • 21