Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


selectNodes - How form query to get required data

From: brianharris@-----------.---------.---
To: NULL
Date: 8/8/2007 6:16:00 AM

I am trying to use selectNodes in a javascript function to select a sub set 
of XML data. Below is a sample of the XML Data.
I have tried many different types of syntax to get it to work, but without 
any success.  I believe that I am not 
specify my select criteria correctly. The latest error I am getting is as 
follows:

	Error: Expression does not return a DOM node

-->"headerDISCREPTABTYP[./DISCREPTABTYP/discrepancytype!value()
    =BELONG$and$ ./DISCREPTABTYP/empcode!value()=114351]"<--

The selection criteria I am trying to use is to select nodes who have child 
nodes that are CDATA nodes with given values.  In this case I want to select 
all DISCREPTABTYP nodes that have discrepancytype = BELONG and empcode = 
114351.

What I am asking then is what is correct syntax for selctNodes to get the 
records I want.

This is an example of what XML data looks likes:
 <?xml version="1.0" ?> 
 <headerDISCREPTABTYP xmlns:dt="urn:schemas-microsoft-com:datatypes">
   <DISCREPTABTYP heading="UNKNOWN" description="UNKNOWN EMPLOYEES IN UNIT" >
     <discrepancytype> <![CDATA[ UNKNOWN  ]]>  </discrepancytype>
     <empcode> <![CDATA[ 62009  ]]>  </empcode>
     <startscan> <![CDATA[ 02/10/2006 09:24:16 am  ]]>   </startscan>
   </DISCREPTABTYP>
   <DISCREPTABTYP heading="BELONG" description="EMPLOYEES WHO BELONG AND ARE 
WORKING IN UNIT" >
     <discrepancytype> <![CDATA[ BELONG  ]]>   </discrepancytype>
     <empcode> <![CDATA[ 114351  ]]>   </empcode>
     <startscan> <![CDATA[ 02/06/2006 08:56:01 am  ]]>  </startscan>
  </DISCREPTABTYP>
  <DISCREPTABTYP heading="BELONG" description="EMPLOYEES WHO BELONG AND ARE 
WORKING IN UNIT" >
    <discrepancytype> <![CDATA[ BELONG  ]]> 
    </discrepancytype>
    <empcode> <![CDATA[ 114351  ]]>   </empcode>
    <startscan> <![CDATA[ 02/07/2006 08:34:21 am  ]]>  </startscan>
  </DISCREPTABTYP>
  <DISCREPTABTYP heading="BELONG" description="EMPLOYEES WHO BELONG AND ARE 
WORKING IN UNIT" >
    <discrepancytype> <![CDATA[ BELONG  ]]>  </discrepancytype>
    <empcode> <![CDATA[ 189191  ]]>  </empcode>
    <startscan> <![CDATA[   ]]>  </startscan>
  </DISCREPTABTYP>
   <DISCREPTABTYP heading="FLOATOUT" description="EMPLOYEES FLOAT OUT OF 
UNIT" >
     <discrepancytype> <![CDATA[ FLOATOUT  ]]>  </discrepancytype>
     <empcode> <![CDATA[ 114351  ]]>  </empcode>
     <startscan> <![CDATA[ 02/10/2006 09:24:16 am  ]]>   </startscan>
   </DISCREPTABTYP>
 </headerDISCREPTABTYP>

Below is an excerpt from my javascript function that calls selectNodes:  
DataSource1 is the XML data file defined elsewhere

function EmployeeAsScanned(discreptype,empcode)
{

var nodePtr;
       nodePtr = DataSource1.selectNodes 
('"headerDISCREPTABTYP[./DISCREPTABTYP/discrepancytype!value()=' + 
discreptype + "$and$./DISCREPTABTYP/empcode!value()=" + empcode + ']"');

//        nodePtr = DataSource1.selectNodes 
('"/headerDISCREPTABTYP/DISCREPTABTYP[discrepancytype!value()=' + discreptype 
+ "$and$empcode!value()=" + empcode + ']"');

//        nodePtr = DataSource1.documentElement.selectNodes 
('"headerDISCREPTABTYP[./DISCREPTABTYP/discrepancytype!value()=' + 
discreptype + "$and$./DISCREPTABTYP/empcode!value()=" + empcode + ']"');
}


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent