Retrieving items from XML file

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi,

I am new to XPath and I am stuck with an expression. I would like to select all servers which the user subscribed to. Here is my XML:
<forums>
<forum>
<name>AAA</name>
<subscribed>1</subscribed>
</forum>
<forum>
<name>BBB</name>
<subscribed>0</subscribed>
</forum>
.....
.....
I would like to retrieve "AAA" since it is a server with "subscribed=1".

I tried various syntaxes, unsuccessfully. This is the last one:

....... ("servers:server[servers:name='" + server + "']/servers:forums/servers:name[subscribed='1']", m_ServersDoc);

Thanks
Mike
 
Hi Mike,

I would recommed that you change your XML to:
<forums><forum name = "AAA" subscribed = "1" /><forum name = "BBB" subscribed = "0" /><forum name = "CCC" subscribed = "1" /><forum name = "DDD" subscribed = "1" /></forums

then you can select all the forums with subscribed= '1' with this:
"//forum[@subscribed='1']

Hope it helps.

Regards
Peter
 
Back
Top