我正在尝试构建一个XPathQuery来获取'ocrx_word'类中的所有内容--我尝试了一些变体,但是没有找到任何可以工作的,我得到了一个Unable to Parse错误。
下面是我的HTML的样子。
<span class='ocr_line' id='line_3' title="bbox 165 201 443 219">
<span class='ocrx_word' id='word_5' title="bbox 165 201 252 217">Associate</span>
<span class='ocrx_word' id='word_6' title="bbox 259 202 335 218">Director</span>
<span class='ocrx_word' id='word_7' title="bbox 341 203 358 218">of</span>
<span class='ocrx_word' id='word_8' title="bbox 361 203 443 219">Athletics</span>
</span>我想要获取标题属性和字符串。
全HTML
NSString *htmlString = [tesseract getHOCRText];
NSData *tutorialsHtmlData = [htmlString dataUsingEncoding:NSASCIIStringEncoding];
// 2
TFHpple *tutorialsParser = [TFHpple hppleWithHTMLData:tutorialsHtmlData];
NSString *tutorialsXpathQueryString = @"//*[@class='ocrx_word']/text()";
NSArray *tutorialsNodes = [tutorialsParser searchWithXPathQuery:tutorialsXpathQueryString];发布于 2014-02-08 20:42:54
此XPath提取标题:
//*[@class='ocrx_word']/@title这段文字摘录如下:
//*[@class='ocrx_word']/text()这就是你需要的吗?
https://stackoverflow.com/questions/21651553
复制相似问题