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

Can get text of a <link></link> node #51

Closed
freewind opened this issue Nov 22, 2010 · 5 comments
Closed

Can get text of a <link></link> node #51

freewind opened this issue Nov 22, 2010 · 5 comments

Comments

@freewind
Copy link

    String html = "<link>http://www.google.com</link><link1>http://link1.com</link1>";
    Document doc = Jsoup.parse(html);
    String link = doc.select("link").first().text();
    System.out.println("Link: " + link);
    String link1 = doc.select("link1").first().text();
    System.out.println("Link1: " + link1);

The result is :

    Link: 
    Link1: http://link1.com

It seems the content of "" node is ignored

@jhy
Copy link
Owner

jhy commented Nov 22, 2010

That's right, link is defined as an empty tag in HTML. Jsoup parses link tags with text content the same was as the browsers do (specifically, the text appears after the node, and if the link was in the head, the text is moved to the body).

@freewind
Copy link
Author

That's a pitty. I hope I can use JSoup to parse XML as well as HTML. The api is so easy to use.
Will JSoup have a version can parse and query XML files?

@jhy
Copy link
Owner

jhy commented Nov 22, 2010

Yep I've been thinking about that, seems like it would be a good idea to implement.

@freewind
Copy link
Author

Great, hope it soon.

@hakos
Copy link

hakos commented Jan 11, 2011

Yes, it would be great with XML support.

This issue was closed.
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

3 participants