Error selecting nodes



I am new to dotnet and I am having trouble reading an xml file.
"The expression passed to this method should result in a NodeSet."

Here is my xml file:

<?xml version="1.0" encoding="Windows-1252" ?>
<root>
<Prov>
<Abrev>AB</Abrev>
<Postals>
<Postal>T</Postal>
</Postals>
</Prov>
<Prov>
<Abrev>BC</Abrev>
<Postals>
<Postal>V</Postal>
</Postals>
</Prov>
....
<Prov>
<Abrev>ON</Abrev>
<Postals>
<Postal>K</Postal>
<Postal>L</Postal>
<Postal>M</Postal>
<Postal>N</Postal>
<Postal>P</Postal>
</Postals>
</Prov>
</root>

I want to read through it for the Abrev and get all the Postal values for it.
I load my file into an xml document and use

XmlNodeList nodeList = xml.SelectNodes("/root/Prov/[@Abrev='" + strProv +
"']/Postals");

to retrieve the node for the variable passes to this function.
Is my syntax incorrect or my xml baddly formed or am I just barking up the
wrong tree?

Thanks in advance.
.



Relevant Pages

  • Re: Error selecting nodes
    ... Here is my xml file: ... I load my file into an xml document and use ...
    (microsoft.public.dotnet.xml)
  • Re: inserting C# variables into XPath expressions
    ... studen77 wrote: ... > I'm trying to extract a specific NodeSet out of an XML file; ...
    (microsoft.public.dotnet.languages.csharp)
  • inserting C# variables into XPath expressions
    ... I'm trying to extract a specific NodeSet out of an XML file; ... like to include a C# string variable as part of the XPATH statement; ...
    (microsoft.public.dotnet.languages.csharp)
  • Xpath c#
    ... Hello I tried to validate XPathExpression against some xml file. ... The problem is that XPathResultType of Expr is NodeSet. ...
    (microsoft.public.dotnet.languages.csharp)