JNYRanger の提案に基づいて、私は昨夜これを思いつきました:
TraverseNodes(xmlSbcCoreData.ChildNodes);
私のXmlDocumentオブジェクトを渡します...
private void TraverseNodes(XmlNodeList nodes) {
Boolean haveValue = false;
foreach (XmlNode node in nodes) {
// Do something with the node.
if (!node.Name.Equals("#text")) {
nodeName = node.Name;
capturedNode = node;
haveValue = false;
} else {
nodeValue = node.Value;
haveValue = true;
}
if (haveValue) {
Debug.WriteLine("-----------------------------------------------------");
Debug.WriteLine("GetRecursiveList - capturedNode: " + capturedNode.Name);
Debug.WriteLine("GetRecursiveList capturedNode Parent: " + capturedNode.ParentNode.Name);
Debug.WriteLine("GetRecursiveList NAME|VALUE: " + nodeName + " | " + nodeValue);
string path = getNodePath(capturedNode);
Debug.WriteLine("GetRecursiveList capturedNode PATH: " + path);
//THIS IS HOW YOU GET THE NODE IN THE OTHER XML
XElement element = xmlNbidData.XPathSelectElement(path);
//AND THEN SET ITS VALUE !!!
element.Value = nodeValue;
}
TraverseNodes(node.ChildNodes);
}
}
これはランタイム (サンプル) です。
GetRecursiveList - captureNode: hraPlan GetRecursiveList CaptureNode 親:overallDeductible GetRecursiveList NAME|VALUE: hraPlan | はい
GetRecursiveList CaptureNode パス: createSbc/createSbcRequest/sbc/coreData/SBCDataContent/importantQuestions/overallDeductible/hraPlan
GetRecursiveList -capturedNode: deductableCrossApply GetRecursiveList CaptureNode 親:overallDeductible GetRecursiveList NAME|VALUE: deductableCrossApply | いいえ
GetRecursiveList CaptureNode パス: createSbc/createSbcRequest/sbc/coreData/SBCDataContent/importantQuestions/overallDeductible/deductableCrossApply
GetRecursiveList - CaptureNode: yearType GetRecursiveList CaptureNode 親:overallDeductible GetRecursiveList NAME|VALUE: yearType | カレンダー
GetRecursiveList CaptureNode パス: createSbc/createSbcRequest/sbc/coreData/SBCDataContent/importantQuestions/overallDeductible/yearType
GetRecursiveList - captureNode: 個別の GetRecursiveList CaptureNode 親: inNetwork GetRecursiveList NAME|VALUE: 個別 | 0
GetRecursiveList CaptureNode パス: createSbc/createSbcRequest/sbc/coreData/SBCDataContent/importantQuestions/overallDeductible/inNetwork/individual