• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Testing for the presence of a node

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,
I am writing an XSL and want to know how can I check an XML document for a presence of a particular node. Let me give you an example...
In my XSL I want to check if the node true is there or the node false is there.
Any help will be appreciated.
Thanks in Advance!!
-Amish
 
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I guess the question is whether there will always be either a true or false node. If so, and assuming that the <Result> node is the context node you could do something like this:

If it is not always guaranteed that a true or false node is always there you can change the otherwise to a when. Also if you want to do this check from a node other than the Result node then the axis and node test (self::node()) will need to be changed.
Hope this helps.
John
[ April 08, 2002: Message edited by: John Wetherbie ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic