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

Forum statistics

Threads
474,000
Messages
2,570,252
Members
46,848
Latest member
CristineKo

Latest Threads

Top