0

I want my xpath query to return something like:
customerName=...
id=...
customField=....

regardless whether those nodes exist in my xml:

<Begin>
<CustomerRet>
<customerName>Jack</customerName>
<customerId>1</customerId>
<customField>A</customField>
</CustomerRet>

<CustomerRet>
<customerName>Jack</customerName>
<customerId>1</customerId>
</CustomerRet>
</Begin>

How do I go about writing my expression? I tried using concat but it's not working for me.

/Begin/CustomRet/concat('customerName=',customerName) | /Begin/CustomRet/concat('customId=',customerId) | /Begin/CustomRet/concat('customField=',customField)

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by xml_looser
0
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text" />

<xsl:template match="CustomerRet">
  customerName=<xsl:value-of select="./customerName"/>
  id=<xsl:value-of select="./customerId"/>
  customeField=<xsl:value-of select="./customField"/>
</xsl:template>

<xsl:template match="/">
   <xsl:apply-templates />
</xsl:template>

</xsl:stylesheet>

Here is the output for the example xml file you supplied

customerName=Jack
  id=1
  customeField=A


  customerName=Jack
  id=1
  customeField=
0

with xquery

let $doc := doc("begin.xml")
for $x in $doc/Begin/CustomerRet

return concat(concat("Name   ", $x/customerName,"&#xA;"), concat("id     ",$x/customerId,"&#xA;"),concat("Field  ",$x/customField,"&#xA;"))
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.