XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 25th, 2003, 05:37 AM
williamcrawley williamcrawley is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: uk
Posts: 91 williamcrawley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
test for the existance of an element

HI All,

Using the DOM (not an XSLT document). how do I test for the existance of an Element?

I have:

<Body>
<Agent>xzt</Agent>
more elements
.....
.......
</Body>

Where say Agent may or may not exist. If Agent exist's then I want to do one thing otherwise I want to do another.

Reply With Quote
  #2  
Old December 22nd, 2003, 05:44 PM
Culland Culland is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 38 Culland User rank is Private First Class (20 - 50 Reputation Level)Culland User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 55 m 6 sec
Reputation Power: 6
Just do a test on the element name. So assuming your context node is the parent of agent, you would do something like the following:

<xsl:choose>
<xsl:when test="agent">
do stuff if agent is present
</xsl:when>
<xsltherwise>
do other stuff
</xsltherwise>
</xsl:choose>

Cul

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > test for the existance of an element


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT