1 using System;
2 using System.XPath;
3 using System.Dom;
4
5 void main()
6 {
7 ustring query = u"/philosophers/philosopher";
8 ustring xml;
9 xml.Append(u"<philosophers>").
10 Append( u"<philosopher name='Plato'/>").
11 Append( u"<philosopher name='Aristotle'/>").
12 Append( u"<philosopher name='Socrates'/>").
13 Append(u"</philosophers>");
14 UniquePtr<Document> doc = ParseDocument(xml, "xml");
15 UniquePtr<XPathObject> o = Evaluate(query, doc.Get());
16 XPathNodeSet* ns = o.Get() as XPathNodeSet*;
17 if (ns != null)
18 {
19 int n = ns->Length();
20 for (int i = 0; i < n; ++i;)
21 {
22 Element* p = (*ns)[i] as Element*;
23 if (p != null)
24 {
25 Console.Out() << p->GetAttribute(u"name") << endl();
26 }
27 }
28 }
29 }