0
XMLファイルを子ノードに基づいて分割し、分割ファイルを表示したいとします。asp.netの子ノードの値に基づいてXMLファイルを分割する
XMLファイルを子ノードに基づいて分割し、分割ファイルを表示したいとします。asp.netの子ノードの値に基づいてXMLファイルを分割する
完全な情報は提供していませんが、要件に近いサンプルコードは次のとおりです。
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
で同様の答えを確認することができますか?サンプルxml? –
分割ファイルを表示することはどういう意味ですか? –