R
Rich P
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
</PropertyGroup>
</Project>
I am using the following code to read the value in the <ProductVersion>
tag in the above xml file:
----------------------------------
XPathDocument doc = new XPathDocument(myxml.xml);
XPathNavigator nav = doc.CreateNavigator();
XPathExpression expr;
expr = nav.Compile("/Project/PropertyGroup/ProductVerion");
XPathNodeIterator iterator = nav.Select(expr);
iterator.MoveNext(); //actually in a loop
XPathNavigator nav2 = iterator.Current.Clone();
Console.WriteLine("version " + nav2.Value.ToString());
----------------------------------
this works if I leave out
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
from the <Project> tag. But the actual file that I am trying to read
contains the "xmlns ..." text and my routine won't read the
ProductVersion tag. I am hoping that the methods I am using here are
outdated and there are newer methods/classes I could use to perform this
read. Any help appreciated.
Thanks
Rich
<Project ToolsVersion="3.5" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
</PropertyGroup>
</Project>
I am using the following code to read the value in the <ProductVersion>
tag in the above xml file:
----------------------------------
XPathDocument doc = new XPathDocument(myxml.xml);
XPathNavigator nav = doc.CreateNavigator();
XPathExpression expr;
expr = nav.Compile("/Project/PropertyGroup/ProductVerion");
XPathNodeIterator iterator = nav.Select(expr);
iterator.MoveNext(); //actually in a loop
XPathNavigator nav2 = iterator.Current.Clone();
Console.WriteLine("version " + nav2.Value.ToString());
----------------------------------
this works if I leave out
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
from the <Project> tag. But the actual file that I am trying to read
contains the "xmlns ..." text and my routine won't read the
ProductVersion tag. I am hoping that the methods I am using here are
outdated and there are newer methods/classes I could use to perform this
read. Any help appreciated.
Thanks
Rich