Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何使用XPath或xgrep在Wikipedia中查找信息?_Xml_Xpath_Wikipedia - Fatal编程技术网

Xml 如何使用XPath或xgrep在Wikipedia中查找信息?

Xml 如何使用XPath或xgrep在Wikipedia中查找信息?,xml,xpath,wikipedia,Xml,Xpath,Wikipedia,我想从维基百科上搜集一些(不是很多)信息。 假设我有一个大学列表和他们的维基百科页面。我可以使用xpath表达式查找该大学的网站(域)吗 举个例子,如果我得到了页面 curl http://en.wikipedia.org/wiki/Vienna_University_of_Technology 此xpath表达式应找到域: http://www.tuwien.ac.at 理想情况下,这应该与Linuxxgrep命令行工具或等效工具配合使用。将h前缀绑定到http://www.w3.org

我想从维基百科上搜集一些(不是很多)信息。 假设我有一个大学列表和他们的维基百科页面。我可以使用xpath表达式查找该大学的网站(域)吗

举个例子,如果我得到了页面

curl http://en.wikipedia.org/wiki/Vienna_University_of_Technology 
此xpath表达式应找到域:

http://www.tuwien.ac.at

理想情况下,这应该与Linux
xgrep
命令行工具或等效工具配合使用。

h
前缀绑定到
http://www.w3.org/1999/xhtml
命名空间URI:

/h:html/h:body/h:div[@id='content']
               /h:div[@id='bodyContent']
                /h:table[@class='infobox vcard']
                 /h:tr[h:th='Website']
                  /h:td/h:a/@href
此外,Wiki页面似乎是格式良好的XML(尽管其服务方式类似于text/html)。因此,如果您有一个XML文档,其页面URL如下:

<root>
   <url>http://en.wikipedia.org/wiki/Vienna_University_of_Technology</url>
</root>

h
前缀绑定到
http://www.w3.org/1999/xhtml
命名空间URI:

/h:html/h:body/h:div[@id='content']
               /h:div[@id='bodyContent']
                /h:table[@class='infobox vcard']
                 /h:tr[h:th='Website']
                  /h:td/h:a/@href
此外,Wiki页面似乎是格式良好的XML(尽管其服务方式类似于text/html)。因此,如果您有一个XML文档,其页面URL如下:

<root>
   <url>http://en.wikipedia.org/wiki/Vienna_University_of_Technology</url>
</root>

嗨@Alejandro,看起来不错,但是我的xgrep工具不接受这个。有没有可以推荐的命令行(Unix/Linux)工具?嗨@Alejandro,看起来不错,但是我的xgrep工具不接受这个。有没有可以推荐的命令行(Unix/Linux)工具?