作者:林小志525家 | 来源:互联网 | 2023-10-11 09:51
Imhavingaproblemwithreadingandprocessingaxmlfile,whichIcannotsolverightnow.Thexml
I'm having a problem with reading and processing a xml file, which I cannot solve right now. The xml has the following structure:
我在读取和处理xml文件时遇到了问题,我现在无法解决。xml具有以下结构:
XmlDocument Doc; int currentid=1;
XmlNode currentlyselectedtestnode =
Doc.SelectNodes("//test[@id = '" +
currentid.ToString() + "']");
string a = currentlyselectedtestnode.SelectSingleNode("//a");
string b = currentlyselectedtestnode.SelectSingleNode("//b");
string c = currentlyselectedtestnode.SelectSingleNode("//c");
Unfortunately, "currentlyselectedtestnode.SelectSingleNode("//a")" will read out all "a"-nodes and not only the one that belongs to test-node with id 1. Why ?! Somehow currentlyselectedtestnode.SelectSingleNode("//a"); works just as if I wrote Doc.SelectSingleNode("//a");
不幸的是,“currentlyselectedtestnode.SelectSingleNode(“//a”)”将读出所有的“a”节点,而不仅仅是id为1的测试节点的节点。为什么? !不知何故currentlyselectedtestnode.SelectSingleNode(" / / ");就像我编写了Doc.SelectSingleNode(“//a”)一样;
How come ?! How can I make it read the children of the specific test-node only ?ectedtestnode.SelectSingleNode("//c");
为什么? !如何使它只读取特定测试节点的子节点?ectedtestnode.SelectSingleNode(“//c”);
1 个解决方案