selectSingleNode problems (xpath)

Discussion in 'JavaScript' started by nevetS, Jan 18, 2006.

  1. #1
    I'm trying to parse some XML data. My problem is that the following line of code:
      m_url = books.selectSingleNode('website').firstChild.text; 
    Code (markup):
    breaks everything if the website is not defined in the XML. I've tried various combinations of
      if(books.selectSingleNode('website' != nothing)  if(books.selectSingleNode('website' != null)  etc. 
    Code (markup):
    but I'm failing to figure out how to test to see if the node exists successfully before trying to use it's value. Sorry... I seem to be having some formatting problems that I'm not smart enough to get around at the moment.
     
    nevetS, Jan 18, 2006 IP