Problems with getting element by id.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,everyone!
I got a problem with check the existence of a xml(kml-google earths) element.The xml file is at the end of the post.I want to check if the Style element with
<br/>
the id of heavy_nomal exist,using vb.net code like this:

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim kmlDoc = <span style="color:Blue; New XmlDocument()
kmlDoc.Load(<span style="color:#A31515; "KmlFullPath")
<span style="color:Blue; Dim rootElement <span style="color:Blue; As XmlElement = kmlDoc.DocumentElement
<span style="color:Blue; Dim documentElement <span style="color:Blue; As XmlElement = rootElement.FirstChild
<span style="color:Blue; Dim m <span style="color:Blue; As <span style="color:Blue; New <span style="color:Blue; Object
m = kmlDoc.GetElementById(<span style="color:#A31515; "heavy_normal")
<span style="color:Blue; If m <span style="color:Blue; Is <span style="color:Blue; Nothing <span style="color:Blue; Then
MsgBox(<span style="color:#A31515; "nothing")
<span style="color:Blue; Else
MsgBox(<span style="color:#A31515; "get it")
<span style="color:Blue; End <span style="color:Blue; If
[/code]
but i always get nothing! <br/>
Could anybody help please! Thanks in advance! <br/>
My xml file is: <br/>
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; UTF-8<span style="color:Black; "<span style="color:Blue; ?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://
www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2"
xmlns:atom="http://www.w3.org/2005/Atom
<span style="color:Blue; <<span style="color:#A31515; Document<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >heavy.kml<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Style <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; heavy_normal<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; IconStyle<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; scale<span style="color:Blue; >1.2<span style="color:Blue; </<span style="color:#A31515; scale<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Icon<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; href<span style="color:Blue; >http://maps.google.com/mapfiles/kml/paddle/wht-
circle.png<span style="color:Blue; </<span style="color:#A31515; href<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Icon<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; IconStyle<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Style<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Document<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; kml<span style="color:Blue; >
[/code]


View the full article
 
Back
Top