Solved

XML / XPATH data field filter

Posted on 2004-04-09
5
319 Views
Last Modified: 2013-11-19
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">

0
Comment
Question by:plq
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:dualsoul
Comment Utility
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.
0
 
LVL 8

Author Comment

by:plq
Comment Utility
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(????)

0
 
LVL 8

Author Comment

by:plq
Comment Utility
ooops what I should have put was

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

Accepted Solution

by:
dualsoul earned 500 total points
Comment Utility
selectNodes(child::*)  - in XPath terms.

but i don't think this will help you much.

But if you come up with some solution, let me know :)
0
 
LVL 8

Author Comment

by:plq
Comment Utility
Nah I tried everything, its not using any xpath, I think its inserting the string directly.

thanks for trying
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now