How do you convert XML Elements to .Net Objects

sibeko

New Member
First time working with XML and while I can iterate through the XML I am having a tough time figuring out the best way to get the elements converted to a .Net object. Specifically I need to get the points that make up an over simplified map. \[code\]Imports SystemImports System.XmlImports System.Xml.XPathImports System.LinqImports System.Xml.LinqModule Module1 Dim s As XDocument =<?xml version="1.0" encoding="UTF-8"?><map:Map xmlns="java:com.raytheon.atc.chi.graphics.geom2d" xmlns:map="java:com.raytheon.atc.chi.adt.map" unit="m" lat="41.975953650" lon="-87.903248430" alt="78.33"><!--ASDE-X DP map for facility:ord Created 10/20/2009 2:22:31 PM--> <map:Layer isVisible="true"><map:Line type="Runway"></map:Line> <map:Region type="Runway"><Surface operation="union"> <Polygon><Point x="1618.87" y="-742.10"></Point> <Point x="1459.74" y="-742.52"></Point> <Point x="1058.11" y="-743.35"></Point> </Polygon> <Polygon><Point x="16.82" y="1760.35"></Point> <Point x="46.31" y="1725.16"></Point> <Point x="16.82" y="1760.35"></Point> </Polygon> <Polygon><Point x="16.82" y="1760.35"></Point> <Point x="16.82" y="1760.35"></Point> </Polygon> </Surface> </map:Region> </map:Layer></map:Map> Public Sub Parse() Dim ns As New XmlNamespaceManager(New NameTable()) ns.AddNamespace("x", "java:com.raytheon.atc.chi.graphics.geom2d") ns.AddNamespace("m", "java:com.raytheon.atc.chi.adt.map") Debug.Print("Points:") Dim elements = s.XPathSelectElements("//m:*//m:Region/x:Surface/x:Polygon/x:Point", ns) For Each element As XElement In elements 'Convert this element to a System.Windows.Point Next End SubEnd Module\[/code\]
 
Back
Top