Parsing content between sibling nodes in poorly formed documents

Discussion in 'XML' started by alex.cline@gmail.com, Sep 18, 2007.

  1. Guest

    I'm trying to write an XSL parser to extract all information between
    two sibling nodes. The problem is, the documents are very poorly
    formatted and that's where I'm running into difficulty. Here is an
    example of the layout of the document:

    <root>
    <header>
    content
    </header>
    <node />

    content to extract.

    <node />
    <footer>
    content
    </footer>
    </root>

    I'm trying to extract all content between the two <node /> elements.
    The data can include either text or other nested elements.

    Thank you.

    -- Alex
    , Sep 18, 2007
    #1
    1. Advertising

  2. wrote:
    > I'm trying to write an XSL parser to extract all information between
    > two sibling nodes. The problem is, the documents are very poorly
    > formatted and that's where I'm running into difficulty. Here is an
    > example of the layout of the document:
    >
    > <root>
    > <header>
    > content
    > </header>
    > <node />
    >
    > content to extract.
    >
    > <node />
    > <footer>
    > content
    > </footer>
    > </root>
    >
    > I'm trying to extract all content between the two <node /> elements.
    > The data can include either text or other nested elements.
    >
    > Thank you.
    >
    > -- Alex
    >


    /root/*[preceding-sibling::node and following-sibling::node]

    David
    David Carlisle, Sep 18, 2007
    #2
    1. Advertising

  3. wrote:
    > I'm trying to write an XSL parser


    Uhm. Terminology problem there. Do you mean an XML parser, or an XSLT
    processor, or an XSLT stylesheet?

    Hard to give you a good answer without being sure what question you're
    asking.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Sep 18, 2007
    #3
  4. Guest

    On Sep 18, 6:16 pm, David Carlisle <>
    wrote:
    >
    > /root/*[preceding-sibling::node and following-sibling::node]
    >
    > David


    Thanks. Your solution led me to mine:

    /root/*[preceding-sibling::node and following-sibling::node]|/root/
    text()[preceding-sibling::node and following-sibling::node]
    , Sep 27, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    2,160
    =?Utf-8?B?YnJpYW5zW01DU0Rd?=
    Feb 16, 2006
  2. Chris
    Replies:
    1
    Views:
    953
    Joris Gillis
    Jun 19, 2006
  3. Replies:
    11
    Views:
    640
    Fredrik Lundh
    Jan 23, 2006
  4. TheDude5B
    Replies:
    4
    Views:
    333
    TheDude5B
    Sep 14, 2007
  5. Replies:
    4
    Views:
    171
    Jim Ley
    Feb 26, 2005
Loading...

Share This Page