How can I get tag's text value with xsl transformation

Rajendar Talatam

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

helderdarocha

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())"/>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I get a html tag's value on React?

how can I select the text in the parent node after the current tag in xsl?

How can I get the value of a HTML text?

how can i get text in selectbox not value

How can i get value of text area?

How can I get a tag's (eg. div, or other) value by parameter name?

How can I get an HTML tag’s value to send an HTML.Action()

How can I get a text with no tag in xml file by python

how I can get the value of url in <p> tag in html

How can I get the value of select tag in Vue JS

How can i get a value of parent div except children tag

How can I get a value from an attribute inside a tag

How can I get a value from an attribute inside a tag as a int

How to write xsl to get the value of all duplicate tag?

Can t get a text as value in select tag

How can I get a ```<td>``` tag without text value occupy a position in a list in Selenium Python when getting table HTML data?

How i can add the style sheet tag to xml using XSL

How do I give a argument to a XSL Transformation?

Whitespace in xsl text transformation

In XSL, how can I return another element when its sibling element's attribute is a certain value?

How to get TAG value/text (like innerHTML)?

how do i get value with xsl:value-of?

How can i tag the annotation in the map and get the tag value while selecting the annotation

xsl transformation: rename a tag (for access)

How can i get the text box value on click button?

how can i get the value of text view in recyclerview item?

How can I get the text / value of a textinput by its ref?

How can I align the tag with the displayed text?

How can I hide an option of a select by it's text value?

TOP Ranking

HotTag

Archive