Solved

XML / XPATH data field filter

Posted on 2004-04-09
5
333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:dualsoul
ID: 10794449
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
ID: 10801904
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
ID: 10801906
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
ID: 10801989
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
ID: 10834630
Nah I tried everything, its not using any xpath, I think its inserting the string directly.

thanks for trying
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

729 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