Wrox Programmer Forums
|
Classic ASP XML Using ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 26th, 2003, 07:22 AM
Registered User
 
Join Date: Nov 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Determine If A Tag or Node Exists

Howdy,

I am retreiving a XML response from a xmlhttp "Post" using the following

.....getElementsByTagName("responseTag").item(0).t ext

My question is: How do I determine if a specific tag exists without causing generating an error? If I attempt to specify a tag name like the above example and it is not present then I get an error. Some of the responses are different per request but most of the retured information is the same.

How can I work around this?

Thanks in Advance,
CoolPeep
 
Old June 14th, 2006, 07:16 PM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to olmec
Default

The way I got round this issue was to read the parent node xml and then check it using a string compare to see if the child node was there. If it was then load that node.

<html>
  <head>
    <script>.........</script>
  </head>
</html>

if head.xml contains "<script" then load head child node script.

Not an elegant solution but it works for the quick job I have to do.

 
Old July 20th, 2006, 06:16 PM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to bobduncan
Default

Could you please be more specific on how to do this? I am connecting with an xml file using javascript and need to determine weather or not a tag or node exists. If the tage exists, a variable is incremented. If not, it stays the same:

var one = response.getElementsByTagName("job").childnodes.on e;
n = 0;
if ( typeof (one) == null ) { n = 9 }
else { n++; }
alert (n);

Thanks,
Bob
http://www.thehappypixel.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML tag from C# or ASP.NET tag from javascript angshujit ASP.NET 2.0 Basics 3 February 16th, 2007 10:07 AM
How to use XPath to retrieve a node tag rs:data? y10k XML 1 May 5th, 2006 01:11 PM
Copying Source Node attributes to output node pvsat XSLT 2 November 3rd, 2005 09:46 AM
Determine if Parent Document Exists echovue Javascript How-To 3 December 8th, 2004 12:31 AM
how to check that node is exists debuajm General .NET 0 June 8th, 2004 02:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.