谢谢你读我的帖子。我试图从下面的xml文件中加载FFTExe的值,但是节点返回null。
下面是我用来读取xml的代码
const string CMD_FFT = "/Command/FFTExe";
string strFile = Application.Current.Resources["ApplicationSettingsFolder"].ToString() + "\\CommandList.xml";
XmlDocument doc = new XmlDocument();
doc.Load(strFile);
XmlNode node = doc.SelectSingleNode(CMD_FFT);
if (null != node) //<-----problem occurs here, node is null!!!
GetAttribute(node, doc, "value", ref FFTExeFile);这里是我的xml文件,我想从条目FFTExe的值中提取"D:\fft\fft.exe“
<?xml version="1.0" ?>
<CommandList>
<Command name="Capture" guid="30db4357-7508-46c9-84eb-3ca0900aa4c5" panel=".\Modules\ExperimentSettingsViewer.dll" description="">
<Experiment value="" />
<OutputPath value="" />
</Command>
<Command name="Run ImageJ Macro" guid="C1391459-132F-45ea-AE72-D7BEB2BD8086" panel=".\Modules\Panel.dll" description="">
<Macro value="" />
<DataFolder value="D:\out\" />
<FFTExe value="D:\fft\fft.exe" />
<Headless value="1" />
</Command>
</CommandList>谢谢你的建议。
我也试过
const string CMD_FFT = "/Command/Command/FFTExe"; 和
const string CMD_FFT = "FFTExe"; 没有运气
发布于 2014-04-25 14:32:05
将您的XPath更改为/CommandList/Command/FFTExe,在开始时用一个斜杠表示从根开始,因此您需要包含CommandList根元素。
有关XPath的其他信息,请参阅此链接。
https://stackoverflow.com/questions/23295867
复制相似问题