Curious,
What you need to do is pass an implementation of IXmlNamespaceResolver
to the overload of the Select method. This implementation would have
namespaces associated with the tags associated with them.
Generally, to do this, you would create an instance of
XmlNamespaceManager and then pass that in with the call to Select.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Curious" <th****@mail.global.net.mt> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
That solved my problem.
Now I am encoutering another problem.
I have the following xml file, and I require to retrieve all the values
for the <stadium:name> tag.
I have done this earlier, but with no namespaces. The code I was using
was the following:
StreamReader reader = new StreamReader(fileName, Encoding.ASCII);
XPathDocument doc = new XPathDocument(reader);
XPathNavigator nav = doc.CreateNavigator();
XPathExpression xpe = nav.Compile("RDF/Description/name");
XPathNodeIterator xpni = nav.Select(xpe);
while(xpni.MoveNext())
{
....
}
How can this be applied having namespaces.
Thanks in Advance
<?xml version="1.0" encoding="us-ascii" standalone="no"?>
<rdf:RDF xmlns:player="http://www.soccermanager.fake/player#"
xmlns:club="http://www.soccermanager.fake/club#"
xmlns:stadium="http://www.soccermanager.fake/stadium#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description
rdf:about="http://www.soccermanager.fake/stadium/Giuseppe Meazza di San
Siro">
<stadium:underSoilSeating>True</stadium:underSoilSeating>
<stadium:capacity>85440</stadium:capacity>
<stadium:location>Milan</stadium:location>
<stadium:covered>False</stadium:covered>
<stadium:seated>85000</stadium:seated>
<stadium:name>Giuseppe Meazza di San Siro</stadium:name>
</rdf:Description>
<rdf:Description
rdf:about="http://www.soccermanager.fake/stadium/Delle Alpi">
<stadium:underSoilSeating>True</stadium:underSoilSeating>
<stadium:capacity>81000</stadium:capacity>
<stadium:location>Torino</stadium:location>
<stadium:covered>False</stadium:covered>
<stadium:seated>79000</stadium:seated>
<stadium:name>Delle Alpi</stadium:name>
</rdf:Description>
</rdf:RDF>