Results 1 to 3 of 3

Thread: Problem with inline elements in XPath

  1. #1
    Join Date
    Aug 2006
    Posts
    227

    Problem with inline elements in XPath

    Hello everybody,

    I have a question concerning XPath expressions. Consider this XML
    snippet:

    <foo title="an attempt">
    <ul>
    <li>This works fine</li>
    <li>Before the inline element <em>Inside the inline element</em> after
    the inline element</li>
    <li>This also works fine</li>
    </ul>
    </foo>

    In order to reach the first list element, I would use the XPath expression "/foo/ul/li[1]", which works fine. (I get the first list element with "This works fine", as expected.)

    However, I need an XPath expression that returns the second list
    element in three "portions":
    - "Before the inline element "
    - "Inside the inline element"
    - " after the inline element"

    I can get the inside of the inline element with "/foo/ul/li/em", but I have no idea how to get the surrounding strings. Any ideas?

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Problem with inline elements in XPath

    In article <eb4e5dda-302b-44cd-ba4e->,

    This will return the text descendants of the <li> elements:

    /foo/ul/li//text()

    Please remember to mention me / in tapes you leave behind.

  3. #3
    Join Date
    Aug 2006
    Posts
    227

    Re: Problem with inline elements in XPath

    hi Reegan, Hello Richard,
    Thank you very much, that seems to work!

Similar Threads

  1. How to Manipulate XML with XPath in VBScript
    By Zavier in forum Software Development
    Replies: 4
    Last Post: 18-04-2010, 03:05 AM
  2. What are the XForms and XPath?
    By Nathen in forum Software Development
    Replies: 5
    Last Post: 03-03-2010, 05:35 AM
  3. What is XPath
    By Eleeazar in forum Software Development
    Replies: 3
    Last Post: 21-11-2009, 05:30 AM
  4. Problem with static and inline in C++
    By Sujit15 in forum Software Development
    Replies: 3
    Last Post: 06-05-2009, 01:15 PM
  5. Photoshop Elements and Premiere Elements go to version 7.0
    By Killen in forum Customize Desktop
    Replies: 2
    Last Post: 29-08-2008, 01:17 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,695,007.22493 seconds with 17 queries