How can I output all of the text in a node, including the text in its children nodes while excluding the text in “a” nodes?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Make use of the built-in template rule for text nodes, which is to copy them to the result. Even for a new processing mode that you specify (“all-but-a” in the code below), the built-in rules will work: for elements, (recursively) process children; for text nodes, copy. You only need to override one of them, the rule for
<a>elements, hence the empty template rule, which effectively strips out the text.For a complete description of how the built-in template rules work, check out the “Built-in Template Rules” section of “How XSLT Works” on my website.