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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
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...
I would like to iterate through them by paragraph without knowing how many
paragraphs there may be.
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 :)
__
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 :)
_