2012-05-02 17 views

答えて

0

完全な情報は提供していませんが、要件に近いサンプルコードは次のとおりです。

ChildNodeという名前の子ノードを多数含むmain.xmlファイルを読み込み、各子ノードごとに別々のファイルを作成します。

XmlDocument xml= new XmlDocument(); 
xml.Load(@"c:\main.xml"); 

XmlNodeList xnRep = xml.DocumentElement.GetElementsByTagName("ChildNode"); 

string strFileName = "ChildNode"; 
int intFileCount; 

for(int i =0; i <xnRep.Count;i++) 
{ 
      //Stores the ChildNode Elements in the Variable 
      strDest = xnRep[i].InnerXml; 

      //Create the New File with the name "ChildNode_1.xml" and "ChildNode_3.xml" 
      XmlWriter xw = XmlWriter.Create(strFileName + "_" + intFileCount + ".xml"); 

      //Write the XML 
      xw.WriteRaw(strDest.ToString()); 

      xw.Close(); 

      intFileCount++; 
} 

また、あなたはあなたがしようとしているかを示すことができsplit xml document into chunks

関連する問題