devxlogo

Filtering On Node Name

Filtering On Node Name

Question:

I have an XML document for news items. It has a tag which has 3 child nodes , and , of which there can be multiples with the one tag.For example:

            

What I want to be able to do is branch to a given template, depending on the name of the node in the order that they displayed, within the tag. I have tried using and , but where I keep getting stuck is in testing for the name of the current node. I could, of course, use a generic tag called, and let it have an attribute called “type” Then I could evaluate the branching the attribute, but, in a way, this defeats the purpose of using XML. What would you suggest?

Answer:

Just use the call and wildcard characters:

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist