xmlを解析し、シリアル化した後、データベースに保存されます。
XMLは次のようになります。
<SampleTypeService>
<Name>sample1</Name>
<URL>sample1</URL>
<SampleTypeService_PK_ID>225d0266-e83a-44b8-88fc-700f6570d530</SampleTypeService_PK_ID>
<SampleTypes>
<SampleType_PK_ID>ef1d8c40-72ce-48d8-b252-9b521e96fa74</SampleType_PK_ID>
</SampleTypes>
</SampleTypeService>
<SampleTypeService>
<Name>sample2</Name>
<URL>sample2</URL>
<SampleTypeService_PK_ID>225reg66-e83a-44b8-88fc-700f6570d530</SampleTypeService_PK_ID>
<SampleTypes>
<SampleType_PK_ID>gh4d8c40-72ce-48d8-b252-9b521e96fa74</SampleType_PK_ID>
</SampleTypes>
</SampleTypeService>
値を文字列に格納してからSampleType_PK_ID
、両方を削除する必要があります
SampleTypes
およびSampleType_PK_ID
ノード。
以下のように削除しようとしています。
foreach (XmlNode SampleNode in SampleList)
{
XmlNodeList ChildList = SampleNode.ChildNodes;
for (int j = 0; j < ChildList.Count; j++)
{
if (ChildList[j].LocalName == "SampleType_PK_ID>")
{
strSampleTypePKID = ChildList[j].InnerText;
if (strSampleTypePKID != null)
{
SampleNode.ParentNode.RemoveChild(ChildList[j]);
j--;
}
}
}
testString = SampleNode.OuterXml;
Console.WriteLine("1):" + strSampleTypePKID);
//Code to serialize and store in database is here.
}
しかしstrSampleTypePKID
、空の文字列として返されます。ここで何が欠けていますか。子を子ノードの値に移動し、その直接の親と一緒に削除するにはどうすればよいですか?