Link to home
Start Free TrialLog in
Avatar of plq
plqFlag for United Kingdom of Great Britain and Northern Ireland

asked on

XML / XPATH data field filter

Hopefully you will only need xpath knowledge to answer this. Don't let the data islands put you off !!!

In internet explorer, you can bind a table to an xml data island as follows:

<xml id="xmlsource">
<root><record><field1>1</field1><field2>Hello</field2></record><record><field1>2</field1><field2>World</field2></record></root>
</xml>

<table datasrc="#xmlsource">
<tr>
<td>
<span datafld="field1"></span>
</td>
<td>
<span datafld="field2"></span>
</td>
</tr>
</table>

Now when I add attributes to the xml root node, the binding stops working. e.g. attr1 in <root attr1="12">

Here's how to fix it:

<root attr1="12"><record><field1>1</field1><field2>Hello</field2></record><record><field1>2</field1><field2>World</field2></record></root>

<table datasrc="#xmlsource" datafld="record">

the extra DATAFLD clause at table level fixes the problem

Question is:

Is there a way of fixing this problem without hard coding the name of the first child node ("record" in this case). I thought perhaps some mixture of slashes and dots might do it ???

<table datasrc="#xmlsource" datafld="youranswerinhereplease">

Avatar of dualsoul
dualsoul

No. As i remeber datasrc - is the extension to provide DSO. DSO is Data Source Object, not XML. It can be some data quering through ODBC for instance. So you should specify field names explicitly.

I think so...but may be i'm wrong.
Avatar of plq

ASKER

In practise I think (in msxml terms) IE will be doing this to expand the table client side :

   for each nod in xmldoc.selectNodes("record")

what would be the syntax for returning the first childNode (as opposed to the first attribute) in a selectNodes statement ? Without specifying "record"

   for each nod in xmldoc.childNodes(0)
=
   for each nod in xmldoc.selectNodes(????)

Avatar of plq

ASKER

ooops what I should have put was

   for each nod in xmldoc.childNodes(0).childNodes
=
   for each nod in xmldoc.selectNodes(????)
ASKER CERTIFIED SOLUTION
Avatar of dualsoul
dualsoul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of plq

ASKER

Nah I tried everything, its not using any xpath, I think its inserting the string directly.

thanks for trying