NervousRex
Programmer
I am new to XML and trying to do a simple read, currently i'm attempting to use XmlTextReader, but if you have a another suggestion that works I am not picky =)
Here is what I have, which doesn't work:
my XML string looks like this currently:
<controlstocheck>
<control id="q1">
<text>spelling test</test>
<space> </space>
</control>
<control id="q8">
<text>more spelling test</test>
<space> </space>
</control>
</controlstocheck>
The XML has the corrected spelling from any text boxes on my form. I need to read in the id of the control, and then set the value of the control to the corrected spelling.
I had to use an attribute value for the control id, if I put it as an element the spellchecker reads it which I don't want.
Here is what I have, which doesn't work:
Code:
Dim sr As StringReader = New StringReader(Me.hidSpellXML.Value)
Dim textReader As XmlTextReader = New XmlTextReader(sr)
While textReader.Read()
' If the node has value
If textReader.HasValue Then
Dim ctrl As Control = FindControl(textReader.Item(0))
' Move to fist element
textReader.MoveToElement()
CType(ctrl, TextBox).Text = textReader.Value.ToString()
End If
End While
my XML string looks like this currently:
<controlstocheck>
<control id="q1">
<text>spelling test</test>
<space> </space>
</control>
<control id="q8">
<text>more spelling test</test>
<space> </space>
</control>
</controlstocheck>
The XML has the corrected spelling from any text boxes on my form. I need to read in the id of the control, and then set the value of the control to the corrected spelling.
I had to use an attribute value for the control id, if I put it as an element the spellchecker reads it which I don't want.