473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Client Script XML XPath problem

I am using client script to handle some XML stuff with MS XMLDOM
But I ran into a problem in selecting the elements using selectNodes method
The XML looks like:
<root>

........................

<Table>

<PK>3</cls_PK>

<Person_Id>1</cls_LampType_FK>

<ClassName>MV-175</cls_ClassName>

<Department_Id>1</cls_LightType_FK>

</Table>

....................

</root>

and here is the javascript code:

var strNodeSelectionString = "Table[Department_Id = 1 and Person_Id = 1 ]";

var oClassNodesList =
xDocClass.documentElement.selectNodes(strNodeSelec tionString);

The problem here is: the code works fine when I select the element only
based on one child-element value, selectNodes will return 0 elements
whenever I use the structure above.

I checked MS XML4.0 SDK and according the XPath syntax definition the XPath
is perfectly ok.

Any thoughs?

Thanks!!!!!
Nov 12 '05 #1
3 1367


news.microsoft.com wrote:

But I ran into a problem in selecting the elements using selectNodes method
The XML looks like:
<root>

.......................

<Table>

<PK>3</cls_PK>

<Person_Id>1</cls_LampType_FK> ^^^^^^^^^^^^^^^ not well-formed
and here is the javascript code:

var strNodeSelectionString = "Table[Department_Id = 1 and Person_Id = 1 ]";

var oClassNodesList =
xDocClass.documentElement.selectNodes(strNodeSelec tionString);

The problem here is: the code works fine when I select the element only
based on one child-element value, selectNodes will return 0 elements
whenever I use the structure above.


I don't see anything wrong with the XPath expression but what you have
posted as XML is not well-formed at all so it is not possible to tell
whether the XPath expression should match anything or not, we need to
see the real XML.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
Sorry for the confusion, the xml looks like:
<?xml version="1.0" standalone="yes"?>

<NewDataSet>

<xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">

<xs:element name="NewDataSet" msdata:IsDataSet="true">

<xs:complexType>

<xs:choice maxOccurs="unbounded">

<xs:element name="Table">

<xs:complexType>

<xs:sequence>

<xs:element name="cls_PK" type="xs:int" minOccurs="0" />

<xs:element name="cls_LampType_FK" type="xs:int" minOccurs="0" />

<xs:element name="cls_ClassName" type="xs:string" minOccurs="0" />

<xs:element name="cls_Wattage" type="xs:int" minOccurs="0" />

<xs:element name="cls_Lumens" type="xs:string" minOccurs="0" />

<xs:element name="cls_LightType_FK" type="xs:int" minOccurs="0" />

<xs:element name="cls_LampSubType_FK" type="xs:int" minOccurs="0" />

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:choice>

</xs:complexType>

</xs:element>

</xs:schema>

<Table>

<cls_PK>1</cls_PK>

<cls_LampType_FK>1</cls_LampType_FK>

<cls_ClassName>MV-100</cls_ClassName>

<cls_Wattage>100</cls_Wattage>

<cls_Lumens>2500~3450</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>2</cls_PK>

<cls_LampType_FK>1</cls_LampType_FK>

<cls_ClassName>MV-1000</cls_ClassName>

<cls_Wattage>1000</cls_Wattage>

<cls_Lumens>28500~48400</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>3</cls_PK>

<cls_LampType_FK>1</cls_LampType_FK>

<cls_ClassName>MV-175</cls_ClassName>

<cls_Wattage>175</cls_Wattage>

<cls_Lumens>6800~7600</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>4</cls_PK>

<cls_LampType_FK>1</cls_LampType_FK>

<cls_ClassName>MV-250</cls_ClassName>

<cls_Wattage>250</cls_Wattage>

<cls_Lumens>8400~10700</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>5</cls_PK>

<cls_LampType_FK>1</cls_LampType_FK>

<cls_ClassName>MV-400</cls_ClassName>

<cls_Wattage>400</cls_Wattage>

<cls_Lumens>13400~19100</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>6</cls_PK>

<cls_LampType_FK>1</cls_LampType_FK>

<cls_ClassName>MV-700</cls_ClassName>

<cls_Wattage>700</cls_Wattage>

<cls_Lumens>33,600</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>7</cls_PK>

<cls_LampType_FK>1</cls_LampType_FK>

<cls_ClassName>MV-75</cls_ClassName>

<cls_Wattage>75</cls_Wattage>

<cls_Lumens>2,250</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>8</cls_PK>

<cls_LampType_FK>3</cls_LampType_FK>

<cls_ClassName>HPS-100</cls_ClassName>

<cls_Wattage>100</cls_Wattage>

<cls_Lumens>8,000</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>9</cls_PK>

<cls_LampType_FK>3</cls_LampType_FK>

<cls_ClassName>HPS-150</cls_ClassName>

<cls_Wattage>150</cls_Wattage>

<cls_Lumens>13,800</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>10</cls_PK>

<cls_LampType_FK>3</cls_LampType_FK>

<cls_ClassName>HPS-200</cls_ClassName>

<cls_Wattage>200</cls_Wattage>

<cls_Lumens>19,800</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>11</cls_PK>

<cls_LampType_FK>3</cls_LampType_FK>

<cls_ClassName>HPS-250</cls_ClassName>

<cls_Wattage>250</cls_Wattage>

<cls_Lumens>25,600</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>12</cls_PK>

<cls_LampType_FK>3</cls_LampType_FK>

<cls_ClassName>HPS-310</cls_ClassName>

<cls_Wattage>310</cls_Wattage>

<cls_Lumens>33,300</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>13</cls_PK>

<cls_LampType_FK>3</cls_LampType_FK>

<cls_ClassName>HPS-400</cls_ClassName>

<cls_Wattage>400</cls_Wattage>

<cls_Lumens>45,000</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>14</cls_PK>

<cls_LampType_FK>3</cls_LampType_FK>

<cls_ClassName>HPS-50</cls_ClassName>

<cls_Wattage>50</cls_Wattage>

<cls_Lumens>3,600</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>15</cls_PK>

<cls_LampType_FK>3</cls_LampType_FK>

<cls_ClassName>HPS-70</cls_ClassName>

<cls_Wattage>70</cls_Wattage>

<cls_Lumens>5,450</cls_Lumens>

<cls_LightType_FK>1</cls_LightType_FK>

</Table>

<Table>

<cls_PK>16</cls_PK>

<cls_LampType_FK>6</cls_LampType_FK>

<cls_ClassName>INC12GB</cls_ClassName>

<cls_Wattage>135</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>3</cls_LampSubType_FK>

</Table>

<Table>

<cls_PK>17</cls_PK>

<cls_LampType_FK>7</cls_LampType_FK>

<cls_ClassName>INC12GA</cls_ClassName>

<cls_Wattage>135</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>3</cls_LampSubType_FK>

</Table>

<Table>

<cls_PK>18</cls_PK>

<cls_LampType_FK>8</cls_LampType_FK>

<cls_ClassName>INC12RB</cls_ClassName>

<cls_Wattage>135</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>3</cls_LampSubType_FK>

</Table>

<Table>

<cls_PK>19</cls_PK>

<cls_LampType_FK>9</cls_LampType_FK>

<cls_ClassName>INC12YA</cls_ClassName>

<cls_Wattage>135</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>3</cls_LampSubType_FK>

</Table>

<Table>

<cls_PK>20</cls_PK>

<cls_LampType_FK>10</cls_LampType_FK>

<cls_ClassName>INC12YB</cls_ClassName>

<cls_Wattage>135</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>3</cls_LampSubType_FK>

</Table>

<Table>

<cls_PK>21</cls_PK>

<cls_LampType_FK>11</cls_LampType_FK>

<cls_ClassName>INC12PED</cls_ClassName>

<cls_Wattage>69</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>3</cls_LampSubType_FK>

</Table>

<Table>

<cls_PK>22</cls_PK>

<cls_LampType_FK>6</cls_LampType_FK>

<cls_ClassName>LED12GB</cls_ClassName>

<cls_Wattage>17</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>4</cls_LampSubType_FK>

</Table>

<Table>

<cls_PK>23</cls_PK>

<cls_LampType_FK>7</cls_LampType_FK>

<cls_ClassName>LED12GA</cls_ClassName>

<cls_Wattage>5</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>4</cls_LampSubType_FK>

</Table>

<Table>

<cls_PK>24</cls_PK>

<cls_LampType_FK>8</cls_LampType_FK>

<cls_ClassName>LED12RB</cls_ClassName>

<cls_Wattage>15</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>4</cls_LampSubType_FK>

</Table>

<Table>

<cls_PK>25</cls_PK>

<cls_LampType_FK>9</cls_LampType_FK>

<cls_ClassName>LED12YA</cls_ClassName>

<cls_Wattage>9</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>4</cls_LampSubType_FK>

</Table>

<Table>

<cls_PK>26</cls_PK>

<cls_LampType_FK>10</cls_LampType_FK>

<cls_ClassName>LED12YB</cls_ClassName>

<cls_Wattage>32</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>4</cls_LampSubType_FK>

</Table>

<Table>

<cls_PK>27</cls_PK>

<cls_LampType_FK>11</cls_LampType_FK>

<cls_ClassName>LED12PED</cls_ClassName>

<cls_Wattage>10</cls_Wattage>

<cls_LightType_FK>2</cls_LightType_FK>

<cls_LampSubType_FK>4</cls_LampSubType_FK>

</Table>

</NewDataSet>

and Javascript is as follows:

var strNodeSelectionString = "Table[cls_LampSubType = " + strSelectedValue+
" and cls_LampType_FK = " + (nTableRowIndex+6).toString()+ "]";

var oClassNodesList =
xDocClass.documentElement.selectNodes(strNodeSelec tionString);

Thank you in advance.

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:u4**************@TK2MSFTNGP14.phx.gbl...


news.microsoft.com wrote:

But I ran into a problem in selecting the elements using selectNodes method The XML looks like:
<root>

.......................

<Table>

<PK>3</cls_PK>

<Person_Id>1</cls_LampType_FK>

^^^^^^^^^^^^^^^ not well-formed
and here is the javascript code:

var strNodeSelectionString = "Table[Department_Id = 1 and Person_Id = 1 ]";
var oClassNodesList =
xDocClass.documentElement.selectNodes(strNodeSelec tionString);

The problem here is: the code works fine when I select the element only
based on one child-element value, selectNodes will return 0 elements
whenever I use the structure above.


I don't see anything wrong with the XPath expression but what you have
posted as XML is not well-formed at all so it is not possible to tell
whether the XPath expression should match anything or not, we need to
see the real XML.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #3


news.microsoft.com wrote:
the xml looks like:
<?xml version="1.0" standalone="yes"?>

<NewDataSet>

<xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Table">

<xs:complexType>

<xs:sequence>

<xs:element name="cls_PK" type="xs:int" minOccurs="0" />

<xs:element name="cls_LampType_FK" type="xs:int" minOccurs="0" />

<xs:element name="cls_ClassName" type="xs:string" minOccurs="0" />

<xs:element name="cls_Wattage" type="xs:int" minOccurs="0" />

<xs:element name="cls_Lumens" type="xs:string" minOccurs="0" />

<xs:element name="cls_LightType_FK" type="xs:int" minOccurs="0" />

<xs:element name="cls_LampSubType_FK" type="xs:int" minOccurs="0" />

</xs:sequence>
Here you have the defined child elements of <Table>, there is
<cls_LampSubType_FK> but below in the XPath you are looking for

var strNodeSelectionString = "Table[cls_LampSubType = " + strSelectedValue+
" and cls_LampType_FK = " + (nTableRowIndex+6).toString()+ "]";


child elements with name cls_LampSubType and those are not found obviously.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
5
by: C Gillespie | last post by:
Dear All, I have an image map that works perfectly in firefox, but not IE can anyone help? The code I use is below. Thanks for any help Colin
3
by: Eugen Gulinsky | last post by:
Hello guys, I am having problems trying to migrate our MSXML4-compatible stylesheets containing large msxsl:script blocks to a formate understandable by System.Xml:Xsl.XslTransform. I keep...
7
by: Mike Rand | last post by:
I am having a really hard time trying to get some client side code hooked up in VS2005, ASP 2.0. The code is in an .inc file (vbscript). The first problem I am encountering is the ASP.NET page...
6
by: Vinit | last post by:
Hi I am passing an arraylist to a c#/.net webmethod from a perl client using soap:lite. The trace shows the elements in the xml request. The arraylist input in the webmethod however does not...
5
by: jorgedelgadolopez | last post by:
Hi all, I am using the xpathnavigator evaluate function on .net (xpath 1 right?). Now I need to expand the code to do multiple contains, compare dates (such as 'before', 'between' and 'after'),...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.