XmlDataSource XPath question

  • Thread starter Thread starter Jones
  • Start date Start date
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>
 
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)
 
Back
Top