XPath Convert Node to String

S

sshahin

Is there a way to Convert a Node to a String using XPath 1.0? For
example, consider the following xml doc:

<?xml version="1.0" encoding="UTF-8"?>
<FaultTo xmlns="http://blah.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Address>http://www.altova.com</Address>

<ReferenceProperties>

<fabrikam:CustomerKey1 xmlns:fabrikam="http://blah.com">3333
<fabrikam:type>TYPE4</fabrikam:type>
</fabrikam:CustomerKey1>

<fabrikam:CustomerKey2
xmlns:fabrikam="http://blah.com">4444</fabrikam:CustomerKey2>

<fabrikam:CustomerKey3
xmlns:fabrikam="http://blah.com">6666</fabrikam:CustomerKey3>

</ReferenceProperties>

<ServiceName PortName="NCName">q:name</ServiceName>
</FaultTo>

I want to be able to extract and return everything contained within
<ReferenceProperties> as a string using xpath 1.0 (I do not wish to use
CDATA or any workarounds like this; basically the XML should be left
untouched with no modifications).
 
S

sshahin

This is not what I am looking for. I am looking to return the
following:

<fabrikam:CustomerKey1 xmlns:fabrikam="http://blah.com">3333
<fabrikam:type>TYPE4</fabrikam:type>
</fabrikam:CustomerKey1>

<fabrikam:CustomerKey2
xmlns:fabrikam="http://blah.com">4444</fabrikam:CustomerKey2>
<fabrikam:CustomerKey3
xmlns:fabrikam="http://blah.com">6666</fabrikam:CustomerKey3>

I seem to agree with you that Xpath may not have a built-in function
for extracting an XML fragment as a string. If there is anyone else
out there who can provide input, I would greatly appreciat it.
 
D

Dimitre Novatchev

This is not what I am looking for. I am looking to return the
following:

<fabrikam:CustomerKey1 xmlns:fabrikam="http://blah.com">3333
<fabrikam:type>TYPE4</fabrikam:type>
</fabrikam:CustomerKey1>

<fabrikam:CustomerKey2
xmlns:fabrikam="http://blah.com">4444</fabrikam:CustomerKey2>
<fabrikam:CustomerKey3
xmlns:fabrikam="http://blah.com">6666</fabrikam:CustomerKey3>

I seem to agree with you that Xpath may not have a built-in function
for extracting an XML fragment as a string. If there is anyone else
out there who can provide input, I would greatly appreciat it.


This is trivial using XSLT.

Read about the
xsl:copy-of

xslt instruction.



Cheers,
Dimitre Novatchev
 

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

No members online now.

Forum statistics

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

Latest Threads

Top