XmlDataSource XPath question

J

Jones

Hello,

I'm trying to figure out what the XPath entry would look like to try
and filter data for my XMLDataSource. I'm thinking I need to use
preceding-node somehow, but not quite sure what the syntax would be.
The xml is below. I want to list all servers for Domain1.

If I use //STATUS/DOMAIN/servers/server, I get all servers. If I
use //STATUS/DOMAIN/servers/server[@name='server1'], I get all server1
servers. How would I format a specific domain?
I tried //STATUS/DOMAIN[@name='Domain1']/servers/server with no
success.

Thanks, Gary


<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="\sheet1.xsl"?>
<STATUS TITLE="Status">
<DOMAIN>
<time>Tue Sep 23 16:03:46 PDT 2008</time>
<name>Domain1</name>
<servers>
<server>
<name>server1</name>
<state>RUNNING</state>
</server>
<server>
<name>server2</name>
<state>RUNNING</state>
</server>
<server>
<name>server3</name>
<state>RUNNING</state>
</server>
</servers>
</DOMAIN>
<DOMAIN>
<time>Tue Sep 23 16:03:50 PDT 2008</time>
<name>Domain2</name>
<servers>
<server>
<name>server1</name>
<state>RUNNING</state>
</server>
<server>
<name>server2</name>
<state>RUNNING</state>
</server>
</servers>
</DOMAIN>
<DOMAIN>
<time>Tue Sep 23 16:03:51 PDT 2008</time>
<name>Domain3</name>
<servers>
<server>
<name>server1</name>
<state>NOTRUNNING</state>
</server>
</servers>
</DOMAIN>
</STATUS>
 
B

bruce barker

look at xml as a tree,

//STATUS/DOMAIN[@name='Domain1']

will return all <DOMAIN>'s with an name attribute = 'Domain'. there are
no matches in your xml as you have no attributes. try:

//STATUS/DOMAIN/[name='Domain1']/servers/server

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top