Menu
  • HOME
  • TAGS

hpple XPath query for complex html

html,ios,parsing,xpath,hpple

You can locate table rows with this: List<WebElement> tableRows = findElements(By.xpath("//TABLE[@class='table_border_both_left']//tr[not(@class='heading_table_top')]")); In a row find the expected data : for (WebElement row : tableRows) { String trainNo = row.findElement(By.xpath("td[1]")).getText(); //or use xpath : td[1]/text() String origin = row.findElement(By.xpath("td[3]")).getText(); //or use xpath : td[3]/text() String deptTime = row.findElement(By.xpath("td[4]")).getText(); //or use xpath...

Hpple parsing HTML with Objective-C

html,ios,objective-c,xpath,hpple

There are 2 small errors in your code. The xPath you used is not correct. You're missing an @ in front of class. The background key is an attribute, so you need to ask the TFHppleElement for its attributes property (which is a dictionary) and get its value via objectForKey:....

Objective C, xpath query not working

objective-c,xpath,hpple

If you want "some text" in your example, rather than [[element firstChild] content], you should use simply [element content]. If your example is representative, but you might want to trim white space and new lines, too. Thus: news.title = [[element content] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; ...

Using wildcards for xpath query in the hpple library for iOS

html,ios,xpath,html-parsing,hpple

Another possible way is using starts-with() function : //a[starts-with(@class,'title')] ...

Parse xml in Xcode with Hpple

ios,objective-c,xml,hpple,tfhpple

The issue is that you're using a HTML parser not an XML parser. From a HTML perspective, you have seven elements between the info open and close tags: some text (newline and spaces) serving tag some text (newline and spaces) calories tag some text (newline and spaces) caloriesFromFat tag some...