1

I have an XML file, that may or may not contain a node called "social".

I want to know if it exists or not using XSLT 1.0.

The problem is I don't know at what level in the XML structure the node will exists. It might be root level, it might be a dozen children down.

Is there an efficient way I can traverse the tree to see if it exists?

1 Answer 1

3

Yes, the test / xpath you need is //social, for example:

<xsl:if test="//social">
    <!-- Logic for if the //social node exists in the document -->
</xsl:if>

See XPath Syntax

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.