The Artima Developer Community
Sponsored Link

Java Buzz Forum
Useful but probably common XPath function

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Chris Winters

Posts: 931
Nickname: cwinters
Registered: Jul, 2003

Daytime: Java hacker; nighttime: Perl hacker; sleeptime: some of both.
Useful but probably common XPath function Posted: Feb 10, 2005 9:12 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Chris Winters.
Original Post: Useful but probably common XPath function
Feed Title: cwinters.com
Feed URL: http://www.cwinters.com/search/registrar.php?domain=jroller.com®istrar=sedopark
Feed Description: Chris Winters on Java, programming and technology, usually in that order.
Latest Java Buzz Posts
Latest Java Buzz Posts by Chris Winters
Latest Posts From cwinters.com

Advertisement

I don't work with XML often enough to have this always at the ready, so: normalize-space() will take care of chomping sequences of whitespace to a single space. So when you're trying to match something like:

<p>This is my
Great Page Number Three
summary
</p>

You can just use something like this and it will do the right thing (using dom4j if that matters):

 String path = "//p[contains( normalize-space( text() ), 'This is my Great Page Number' )]";
 List matching = doc.selectNodes( path );

(...and when I say 'XPath function' I actually mean 'XSLT function also used by XPath'. But since I'm just using XPath right now...)

Read: Useful but probably common XPath function

Topic: How to run javac 1.5 (or beyond) compiler for JSP compilation in Tomcat 5.5 with generics... Previous Topic   Next Topic Topic: Resources for Automatic Updates of Java Applications

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use