<p align=\"left\"><b><font face=\"Arial\" size=\"2\">GFI MailSecurity's HTML 
threat engine found HTML scripts in this email and has disabled 
them.</font></b></p>The <xmlpeek> task is really nice but has one or two 
wrinkles.  I have a
few situations where I have to test whether a particular element exists,
and in a couple of cases I have to do something when a particular value
does *not* exist.  In these cases I have to either use the failonerror
attribute or the <trycatch> task from NantContrib.

This leads to both build files and logs that are a little cluttered.
Therefore, I've written a <Xcript><!-- task that has three (very basic)
functions in it:

 * xml::get-value
Get an element's value as a string.  Acts in a similar way to the
<xmlpeek> task, and was just meant as an alternative to it.  Doesn't
catch any exceptions.

 * xml::get-value-without-failing
Get an element's value as a string.  Acts in a similar way to the
<xmlpeek> task if you use failonerror="false", just without the log
clutter.  Catches all exceptions, so it won't throw an error under any
circumstances.

 * xml::value-exists
Returns a bool value indicating whether or not the element exists.  This
is based on whether SelectSingleNode returns a NullReferenceException.
If so, then this function returns a false value (the <xmlpeek> task
throws an error).

The code for these functions can be found at
http://nant.sourceforge.net/wiki/index.php/User%20submitted%20%3Cscript%
3E%27s (you'll need to scroll down)

There's probably more that can be added.  If you have any ideas for
other functions, feel free to add them or let me know.

Regards

John


**********************************************************************
Privileged/Confidential Information may be contained in this 
message. If you are not the addressee indicated in this 
message (or responsible for delivery of the message to such 
person), you must not copy, distribute or take any action in 
reliance to it.
In such case, you should destroy this message and kindly 
notify the sender by reply email. Please advise immediately 
if you or your employer do not consent to Internet email for 
messages of this kind. Opinions, conclusions and other 
information in this message that do not relate to the official 
business of Minorplanet Systems Plc shall be understood as 
neither given nor endorsed by it.
**********************************************************************



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Nant-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to