Menu

Multiple paragraphs make story (keep &lt...

Help
Jim
2012-08-01
2012-09-04
  • Jim

    Jim - 2012-08-01

    I have used the New York times as a starting point and so far everything works
    great except my story text is made up of multiple paragraphs contained in


    tag.

    When I use let $text := data($doc//div/p) to capture the story it concatinates
    all the content in the

    tags into the variable and stores it. How can I
    retain each section wrapped in its own

    tag?

     
  • Enissay

    Enissay - 2012-08-06

    well this is an xPath/xQuery question :)

    I didnt get what you mean, but you can call the Nth section this way: let
    $NthText := data($doc//div/p)

    I don't know if this answers your question...

     
  • Jim

    Jim - 2012-08-07

    I would like to iterate through them by paragraph without knowing how many
    paragraphs there may be.

     
  • Selvin Fehric

    Selvin Fehric - 2012-08-08

    Well you can iterate through p elements until their content is empty. Or
    something like that.

    Example of solution:

    Write while loop and then inside it use something like:

    let $text := concat($text, data($doc//div/p_))

    let $i := $i +1

    or something like that, I am not sure for syntax. In condition of while loop
    set if data($doc//div/p_) is not empty.

    Play with it :)

    __

     
  • Selvin Fehric

    Selvin Fehric - 2012-08-08

    Sorry, this editor recognized _ as italic tag.

    So it was:

    let $text := concat($text, data($doc//div/p))

    let $index := $index +1

    or something like that, I am not sure for syntax. In condition of while loop
    set if data($doc//div/p) is not empty.

    Play with it :)

    _

     

Log in to post a comment.