Attributes in Element Returns Nothing when Reading and Not in Count

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have an XML document that is very simple. I am trying to read the "destination" attributes in the ParseKeyWord element, as shown in the snippet below:

<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; ?>
<span style="color:Blue; <<span style="color:#A31515; ParseKeyWords<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ParseKeyWord <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; NextWord<span style="color:Black; " <span style="color:Red; destination<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; /my:myFields/up:UnitPlan/@code<span style="color:Black; "<span style="color:Blue; >Unit Code:<span style="color:Blue; </<span style="color:#A31515; ParseKeyWord<span style="color:Blue; >

[/code]
I have tried using an XmlTextReader and LINQ, but both result in Nothing being returned. While debugging, I found that the Attributes.Count =1, not 2. Furthermore, my loop only continues until the tenth ParseKeyWord element, then jumps out and continues. The
remaining elements are not read. The type attribute is read well and consistently.


<div style="color:Black;background-color:White; <pre>
destination = <span style="color:Blue; CStr(xParse.Attribute(<span style="color:#A31515; "destination"))
[/code]

I went to the document, which is a file in my solution, and discovered that when I hover over the attribute name, it shows a tag indicating the value is Nothing. It looks like it is picking it up as a reference to some place in the xml document itself, but
this document only has ParseKeyWord elements, and it is an attribute, which I though could only be text.
I guess I missed something basic while learning to handle XML. I would appreciate it if you can point out what I am doing wrong.
Thanks,

View the full article
 
Back
Top