XMLTextReader Problem

  • Thread starter msnews.microsoft.com
  • Start date
M

msnews.microsoft.com

Hi All,

I have some code that uses the XMLTextReader to parse a document. When I
iterate through the nodes on desktop the reader.value method returns the
inner contents of the node correctly, however when I do the same on the PPC
the reader method returns an empty string. Does anyone know what might be
the cause of this.

I am using CF 1.0 SP3 if that is any indication

Any help is appreciated
Mark


' Example of the code
do while reader.read
console.writeline(reader.name & " : " & reader.value)
loop
 
S

Sergey Bogdanov

The XmlTextReader for CF and FF always returns empty value for NodeType
equals to XmlNodeType.Element. The reader has forward only behaviour and
to predict element inner text it would have read till the end of an
element and then restored to the previous position. That is why the
value for such node types is empty.

However, you can manually read the current element inner XML by using
ReadInnerXml method (as I said, you can not return to the previous
position after that):

while(xtr.Read())
{
if (xtr.NodeType == XmlNodeType.Element)
{
string innerXmlOfCurrentElement = xtr.ReadInnerXml();
}
}

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
M

msnews.microsoft.com

Thanks very much,

I figured it out after walking away from the computer for a little while.
Too much working with the XMLDocument class and not enough with this one.

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top