2012-03-06 20 views
0

これは追加したい子ノードですが、createElementメソッドを使用すると、xmlnsという属性が自動的に含まれますが、以下のノードをxmlに追加する方法はありません。C#で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> 

私のプログラム:

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"); 
     } 
    } 
+0

誰も投稿に返信していません –

答えて

0

この意志をいいえ作成しないこのように

<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" /> 

xmlns属性を削除します。

関連する問題