它是一个.vbproj,看起来像这样
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>15a7ee82-9020-4fda-a7fb-85a61664692d</ProjectGuid>
Run Code Online (Sandbox Code Playgroud)
我想得到的只是ProjectGuid,但是当命名空间存在时它不起作用......
Dim xmlDoc As New XmlDocument()
Dim filePath As String = Path.Combine(mDirectory, name + "\" + name + ".vbproj")
xmlDoc.Load(filePath)
Dim value As Object = xmlDoc.SelectNodes("/Project/PropertyGroup/ProjectGuid")
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能解决这个问题?
我将以下字符串加载到XML文档:
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>El cliente con los parámetros introducidos no existe./faultstring>
<detail>
<ns:ClienteWSDo29Exception xmlns:ns="http://services.do29.imq.es">
<Do29Exception xmlns="http://services.do29.imq.es" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ax211="http://model.do29.imq.es/xsd" xmlns:ax213="http://dto.do29.imq.es/xsd" xmlns:ax29="http://exception.do29.imq.es/xsd" xsi:type="ax29:Do29Exception">
<ax29:classname>class es.imq.do29.dao.ClienteDaoImpl</ax29:classname>
<ax29:trace xsi:nil="true" />
<ax29:previous xsi:nil="true" />
<ax29:method>getCliente</ax29:method>
<ax29:id>1</ax29:id>
<ax29:message>El cliente con los parámetros introducidos no existe.</ax29:message>
</Do29Exception>
</ns:ClienteWSDo29Exception>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
然后在xml中使用命名空间的情况我试过:
XmlDocument xmldocu = new XmlDocument();
xmldocu.LoadXml(xml);
XmlNamespaceManager namespaces = new XmlNamespaceManager(xmldocu.NameTable);
namespaces.AddNamespace("ax29", "http://services.do29.imq.es");
XmlNode nodemsgx = xmldocu.SelectSingleNode("//message", namespaces);
XmlNode nodemsg = xmldocu.SelectSingleNode("//ax29:message", namespaces);
Run Code Online (Sandbox Code Playgroud)
但是nodemsgx和nodemsg是null:S怎么做正确的方法呢?我使用//消息因为我想要获得该类型的任何节点而不是该节点的特定路径...