Xml 查找嵌入的命名空间uri';s
考虑到以下内容:Xml 查找嵌入的命名空间uri';s,xml,xpath,Xml,Xpath,考虑到以下内容:您会注意到,此xml示例中嵌入了一个组织节点,该节点具有“用xmlns=“”声明的自己的名称空间” 这是这样声明的,而不是使用前缀。 是否有任何方法可以使用xpath查找xml文档中声明的所有名称空间 我尝试了一些变体,不幸的是,xmlns没有像文档的任何其他属性一样被对待(出于明显的原因),我无法找到使用xpath将它们导出的方法 //@*例如,不包括它们 我需要文档中所有xmlns属性的列表 <rss version="2.0" xmlns:a10="http://ww
您会注意到,此xml示例中嵌入了一个组织节点,该节点具有“用xmlns=“”声明的自己的名称空间” 这是这样声明的,而不是使用前缀。 是否有任何方法可以使用xpath查找xml文档中声明的所有名称空间 我尝试了一些变体,不幸的是,xmlns没有像文档的任何其他属性一样被对待(出于明显的原因),我无法找到使用xpath将它们导出的方法 //@*例如,不包括它们 我需要文档中所有xmlns属性的列表
<rss version="2.0" xmlns:a10="http://www.w3.org/2005/Atom">
<channel xmlns:media="http://search.yahoo.com/mrss">
<title>Search Results Title</title>
<link>http://acme.co.za/searchResults</link>
<description>Search Results Descrption</description>
<item>
<guid isPermaLink="false">uuid:169d3229-3b99-4647-9791-492bbbf4c419/PGS0900.PDF</guid>
<link>link</link>
<title>Title</title>
<description>This page...</description>
<media:thumbnail url="..." width="100" height="100"></media:thumbnail>
<Organisation xmlns="http://acme.co.za/MYNAMESPACE" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>Volkswagen</Name>
<Business>Kraft-durch-Freude-Wagen</Business>
<Type>Public</Type>
<RegistrationNumber>5908213224080</RegistrationNumber>
</Organisation>
</item>
</channel>
</rss>
搜索结果标题
http://acme.co.za/searchResults
搜索结果描述
uuid:169d3229-3b99-4647-9791-492BBF4C419/PGS0900.PDF
链接
标题
这一页。。。
大众
卡夫·德尔奇·弗洛伊德·瓦根
公开的
5908213224080
您应该能够执行类似于//名称空间:
但是,假设这是可行的,它将按文档顺序为您提供一个名称空间节点列表,其中包含大量重复项。您最好通过DOM简单地遍历文档,积累名称空间集(无重复)。请注意,您需要检查属性和元素。正确的语法是
//名称空间-uri()
这将提供文档中的所有名称空间
<rss version="2.0" xmlns:a10="http://www.w3.org/2005/Atom">
<channel xmlns:media="http://search.yahoo.com/mrss">
<title>Search Results Title</title>
<link>http://acme.co.za/searchResults</link>
<description>Search Results Descrption</description>
<item>
<guid isPermaLink="false">uuid:169d3229-3b99-4647-9791-492bbbf4c419/PGS0900.PDF</guid>
<link>link</link>
<title>Title</title>
<description>This page...</description>
<media:thumbnail url="..." width="100" height="100"></media:thumbnail>
<Organisation xmlns="http://acme.co.za/MYNAMESPACE" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>Volkswagen</Name>
<Business>Kraft-durch-Freude-Wagen</Business>
<Type>Public</Type>
<RegistrationNumber>5908213224080</RegistrationNumber>
</Organisation>
</item>
</channel>
</rss>
问候
Craig./*/namespace-uri()只显示元素的名称空间;但是,这两个表达式都将返回重复的表达式。