Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not work with ![CDATA[xxxx]] #46

Closed
zhuhejin opened this issue Oct 27, 2015 · 8 comments
Closed

not work with ![CDATA[xxxx]] #46

zhuhejin opened this issue Oct 27, 2015 · 8 comments

Comments

@zhuhejin
Copy link

Ono does not work with ![CDATA[xxxx]]

@zhuhejin
Copy link
Author

use like [[[aElement childrenWithTag:@"text"] firstObject] stringValue] can fix this bug

@cezheng
Copy link
Contributor

cezheng commented Oct 27, 2015

@zhuhejin Would you mind sharing an example(code & relevant XML)?

@zhuhejin
Copy link
Author

@cezheng
self. commentText =[[aElement firstChildWithTag:@"text"] stringValue]; //return nil;
self.commentText=[[[aElement childrenWithTag:@"text"] firstObject] stringValue]; // return correct;

@gcox
Copy link

gcox commented Oct 31, 2015

@cezheng Here's an example tag whose stringValue returns @"" for me. @zhuhejin's suggested workaround does not work for this case and also returns @"".

<link>
    <![CDATA[http://www.earwolf.com/show/comedy-bang-bang/]]>
</link>

Other tags containing text wrapped in parses without a problem.

@cezheng
Copy link
Contributor

cezheng commented Oct 31, 2015

@gcox I found that if you read the document as HTML, then CDATA won't be recognized, you have to treat it as an XML document

@gcox
Copy link

gcox commented Oct 31, 2015

@cezheng I'm not sure what you mean, the NSData object I'm using to load the ONXMLDocument is downloaded from a server returning application/rss+xml. Is -[ONXMLElement firstChildWithTag:] meant to be used against HTML documents only?

I did find that grabbing the ONOXMLElement from the result of -[ONOXMLDocument XPath:] got me an ONXMLElement object that returns the correct stringValue.

@gcox
Copy link

gcox commented Oct 31, 2015

@cezheng I figured out the problem...it's my fault. There was another 'link' tag with a namespace, I incorrectly assumed firstChildWithTag:@"link" would consider <atom:link to be a match. There is of course no string value for the atom:link tag.

@mattt
Copy link
Owner

mattt commented Mar 21, 2018

Apologies for not responding to this sooner, @zhuhejin. If this is still an issue for you, please let me know, and I'll reopen. Thanks!

@mattt mattt closed this as completed Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants