XQuery Help

J

jhagemeier

Hello,

I'm looking for some help with an xquery.

My XML looks like this:

<EmailContentData>
<EMAIL>[email protected]</EMAIL>
<GPP_NBR>1111222233334444</GPP_NBR>
<!-- other elements here -->
</EmailContentData>

I need to create an xquery that will return ALL the nodes within the
<EmailContentData> in concatenated string form, with a little bit of
formating. Like this:

'&[email protected]&GPP_NBR=1111222233334444'

The difficulty I'm having is figuring out how to generically
concatenate data across multiple nodes without referencing the node
names directly. I need the xq to be generic because the
<EmailContentData> nodes may vary by document.

Any help would be sincerely appreciated.

Thanks,
Jeff
 
M

Martin Honnen

My XML looks like this:

<EmailContentData>
<EMAIL>[email protected]</EMAIL>
<GPP_NBR>1111222233334444</GPP_NBR>
<!-- other elements here -->
</EmailContentData>

I need to create an xquery that will return ALL the nodes within the
<EmailContentData> in concatenated string form, with a little bit of
formating. Like this:

'&[email protected]&GPP_NBR=1111222233334444'

The difficulty I'm having is figuring out how to generically
concatenate data across multiple nodes without referencing the node
names directly. I need the xq to be generic because the
<EmailContentData> nodes may vary by document.

Here is an example that works for me with Saxon:

declare namespace saxon="http://saxon.sf.net/";
declare option saxon:eek:utput "method=text";
concat('&amp;', string-join(for $el in doc('test2008010201.xml')/*/*
return concat(local-name($el), '=', data($el)), '&amp;'))
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top