473,508 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlDataSource XPath question

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>
Sep 30 '08 #1
1 1340
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)

Jones wrote:
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>

Oct 1 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3150
by: mike | last post by:
can somebody please show me some code that will let me populate a checkboxlist from the xmldatasource, and have the text property set to the names in the xml file thanks you can also email me...
0
1467
by: Thor W Hammer | last post by:
Is it possible to use dynamic xpath expressions with the <%#XPath("..")%> syntax and XmlDataSource? This is a couple of examples to illustrate what I think about: 1: <%#XPath("*")%> 2:...
3
9155
by: Brian | last post by:
Using external XML, I'm trying to build a quiz, but I can't seem to specify the DataSource for the RadioButtonList within a Repeater ItemTemplate. I've tried a number of approaches, but I haven't...
0
1348
by: Jon Davis | last post by:
My repeater is not repeating any items. I am trying to use an XmlDataSource to load a custom .sitemap file having content similar to as follows: <siteMap> <siteMapNode title="Home"...
1
3163
by: Disccooker | last post by:
i am trying to use XPath and the XMLDataSource to display data from an XMLDocument and am getting nowhere. What i would like to do is have a repeater display a label for Seed, label for Team Name...
2
1824
by: rote | last post by:
I have a code below i'm trying to test It had a DataSetDatasource but i thinks its deprecated if yes what can i use in this scenario below? I used XmlDatasource but its saying it can't find the...
0
1750
by: pompair | last post by:
Hello, I'm making a quiz game for fun. I have an xml file like this: <?xml version="1.0" encoding="utf-8" ?> <results> <index>99</index> <answers>11</answers> <questions> <question id="1">
8
2058
by: Wessel Troost | last post by:
We are using an XML data source in the Page_Load event of an ASP.NET page, like: protected void Page_Load(object sender, EventArgs e) { // Retrieve XML from web service for product idea in URL...
1
1788
by: Sean | last post by:
I am experiencing a strange problem using the XMLDataSource and DataList controls which I cannot seem to resolve. I am using the controls to read and display a variety of RSS feeds. On my local...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.