How do I strip out a set of tags in XQuery but still leave its text there? For example, if I have:
<root>
<childnode>This is <unwantedtag>some text</unwantedtag> that I need.</childnode>
</root>
How do I strip out the unwanted tag to get:
<root>
<childnode>This is some text that I need.</childnode>
</root>
Actually, what I really want to end up with is just the text, like:
This is some text that I need.
When I do the following:
let $text := /root/childnode/text()
I get:
This is that I need.
It's missing the some text
part of it.
Any ideas on how to return This is some text that I need.
?
Thank you.
Isn't it the string-value of childnode, that you are interested in (as opposed to a sequence of text nodes, or a simplified element)? You can get the string-value from fn:string: