我正在使用Hpple传递一个HTML文件。HTML文件非常类似于以下内容。
<div class="entry">
<p>some text here
<a>Inside a</a>
another text here
</p>
<div class="caption">
caption here
</div>
<p>Blah
</p>
</div>我想看到的结果是“这里有一些文本--这里的另一个文本-- Blah”(它忽略了所有内容都是标题div,包括内部和后面的内容)。
以下是我尝试过的一些查询:
"//div[@class='entry']/p"结果:"some text here""//div[@class='entry']//p"结果:"some text here caption here Blah""//div[@class='entry']/p//text()"结果:Nothing谢谢。
发布于 2013-04-25 12:56:40
你可能自己回答过这个问题,但我只是遇到了类似的问题。为了得到我用过的文字
//div@class='entry'//a@inside//*
这让我得到了你在里面所称的文字。如果这有用的话请告诉我。我自己还在学习如何解析HTML。祝好运。
发布于 2013-04-29 12:54:30
试试这个:
//div[@class='entry']//p//text() - should return "Some text here another text here Blah"
//div[@class='entry']//text() - should return "Some text here another text here caption here Blah" https://stackoverflow.com/questions/16143328
复制相似问题