You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to have a method similar to stringValue which doesn't recursively prints everything under a certain XPathQuery. Here is the full code + HTML and the produced output by Ono plus which output I'd like to have.
My XPath Query: XPathQuery: //div[@class='thread']
FirstName LastName, SecondNameFirst SecondNameLast
FirstName LastName
Wednesday, December 24, 2014 at 6:57pm UTC+01
This is a dummy text
SecondNameFirst SecondNameLast
Wednesday, December 24, 2014 at 6:56pm UTC+01
And a 2nd one just to show off
Another, User
Another
Monday, April 27, 2015 at 10:54pm UTC+02
Text: 2.1
User
Thursday, February 26, 2015 at 5:41pm UTC+01
Text: 2.2
Another
Thursday, February 26, 2015 at 4:25pm UTC+01
Text: 2.3
I would prefer to have an output similar to hpple which is:
FirstName LastName, SecondNameFirst SecondNameLast
Another, User
hpple code:
tutorialsParser = [TFHpple hppleWithHTMLData:file];
tutorialsNodes = [tutorialsParser searchWithXPathQuery:xPath];
for (TFHppleElement *element in tutorialsNodes) {
NSLog(@"%@", [[element firstChild] content].trim);
}
And I don't want to use hpple since it is too slow.
Here is my input HTML file:
<!DOCTYPEhtml>
<html>
<head><title/></head>
<body>
<divclass="thread">FirstName LastName, SecondNameFirst SecondNameLast
<divclass="message">
<divclass="message_header">
<spanclass="user">FirstName LastName</span>
<spanclass="meta">Wednesday, December 24, 2014 at 6:57pm UTC+01 </span>
</div>
</div>
<p>This is a dummy text</p>
<divclass="message">
<divclass="message_header">
<spanclass="user">SecondNameFirst SecondNameLast</span>
<spanclass="meta">Wednesday, December 24, 2014 at 6:56pm UTC+01</span>
</div>
</div>
<p>And a 2nd one just to show off</p>
</div>
<divclass="thread">Another, User
<divclass="message">
<divclass="message_header">
<spanclass="user">Another</span>
<spanclass="meta">Monday, April 27, 2015 at 10:54pm UTC+02</span>
</div>
</div>
<p>Text: 2.1</p>
<divclass="message">
<divclass="message_header">
<spanclass="user">User</span>
<spanclass="meta">Thursday, February 26, 2015 at 5:41pm UTC+01</span>
</div>
</div>
<p>Text: 2.2</p>
<divclass="message">
<divclass="message_header">
<spanclass="user">Another</span>
<spanclass="meta">Thursday, February 26, 2015 at 4:25pm UTC+01</span>
</div>
</div>
<p>Text: 2.3</p>
</div>
</body>
</html>
The text was updated successfully, but these errors were encountered:
//remove extra spaces on left or right
lettrimmedValue=(element.childrenWithTag("td")[3]as!ONOXMLElement).stringValue().trim()
//remove white space
letcleanedValue=(element.childrenWithTag("td")[3]as!ONOXMLElement).stringValue().clean()
//or chain them together
letextraCleanValue=(element.childrenWithTag("td")[3]as!ONOXMLElement).stringValue().clean().trim()
I would like to have a method similar to stringValue which doesn't recursively prints everything under a certain XPathQuery. Here is the full code + HTML and the produced output by
Ono
plus which output I'd like to have.My XPath Query:
XPathQuery: //div[@class='thread']
Ono
code:Which prints:
I would prefer to have an output similar to hpple which is:
hpple code:
And I don't want to use hpple since it is too slow.
Here is my input HTML file:
The text was updated successfully, but these errors were encountered: