I have a very simple xml file:
<?xml version="1.0" encoding="utf-8"?> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <metadata> <id>SomeSoftware</id> <title>Some Software</title> <version>1.2.3</version> </metadata> </package>
From this file I would like to extract the value of the version node, using F#.
let xmlDocument = new XmlDocument() let namespaces = new XmlNamespaceManager(xmlDocument.NameTable); namespaces.AddNamespace("ns", "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"); xmlDocument.Load "software.nuspec" let node = xmlDocument.SelectSingleNode "/package/metadata/version" :?> XmlElement if node = null then printfn "unable to find version" else printfn "%s" node.Value
I have tried a few variations on this, but I don't seem to be able to print the version to my console.
No comments:
Post a Comment