Reputation: 282
I have a XML like this
<Error>An error has occured while saving the workflow
<ErrorFile>C:\temp\Log\ErrorImages\accountwf38_1401351602333.png</ErrorFile>
</Error>
when I write an XSL transformation like this
<xsl:value-of select="Error"/>
I am getting the entire error value as output, including the error file value.
But I need only An error has occured while saving the workflow
as output. How can I write a transformation for that?
Thanks
Rajendar
Upvotes: 0
Views: 43
Reputation: 23637
i am getting entire error value as output including error file value but i need only An error has occurred while saving the workflow as output
The <Error>
element has three child nodes. A text node, an element (ErrorFile
) node and another text node (containing a new line and some spaces before the end tag)`.
The XPath expression you used selects the entire Error
node, which is converted to its string value when used in <xsl:value-of>
, which consists of of all of its descendants converted to string.
To obtain what you need you can use this expression:
<xsl:value-of select="Error/text()"/>
which will select only the child text nodes.
And you can get rid of the unnecessary spaces using:
<xsl:value-of select="normalize-space(Error/text())"/>
Upvotes: 1