XmlDocument.SelectSingleNode和xmlNamespace問題我正在將字符串加載到包含以下結(jié)構(gòu)的XML文檔:<?xml version="1.0" encoding="utf-8"?><Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Include="clsWorker.cs" />
</ItemGroup> </Project>然后我將所有加載到xmldocument:XmlDocument xmldoc = new XmlDocument();xmldoc.LoadXml(Xml);然后出現(xiàn)以下問題:XmlNode Node = xmldoc.SelectSingleNode("//Compile"); // return null當(dāng)我從根元素(Project)中刪除xmlns屬性時,它的工作正常,如何改進(jìn)我的SelectSingleNode以返回相關(guān)元素?
- 3 回答
- 0 關(guān)注
- 657 瀏覽
添加回答
舉報(bào)
0/150
提交
取消