Xml 使用命名空间属性和SelectSingleNode属性的XPATH
我得到了这个XML—它是Excel Ribbon的_rels文件:Xml 使用命名空间属性和SelectSingleNode属性的XPATH,xml,excel,xpath,namespaces,vba,Xml,Excel,Xpath,Namespaces,Vba,我得到了这个XML—它是Excel Ribbon的_rels文件: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Id="rId3" Type="http://schemas.openxmlformats.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
<Relationship Id="cuID14" Type="http://schemas.microsoft.com/office/2007/relationships/ui/extensibility" Target="customUI/customUI14.xml"/>
</Relationships>
我发现了很多示例,但没有任何示例使用具有定义名称空间的属性。我尝试过类似于
oXMLDoc.SelectSingleNode(“//rels:Relationship[@rels:Type='http:
…您的第二次尝试非常成功
而不是
//rels:Relationship[@rels:Type='http:...`
你应该使用
//rels:Relationship[@Type='http:...
因为属性不属于默认名称空间——只属于元素
另请参见:
//rels:Relationship[@Type='http:...