Using XmlTextReader in JavaScript?

Hello! First, let me say that I’m still new to Unity, and to Mono/.NET, so I apologize if I’m doing something obviously wrong.

myXmlReader = new XmlTextReader("http://fraticelli.info/temp/test.xml");
while ( myXmlReader.Read() ) {
	print( myXmlReader.ReadString() );
}

I’m trying to load XML off the web, and read through it with an XmlTextReader object. The code seems to work (there are no errors), except, every line read from the file is blank – there are 11 blank lines in my console after loading a 12-line XML file. (There were 8 blank lines for a 9-line XML file.)

The same thing happens whether I create the XmlTextReader with the URL of the file, or whether I fetch that URL into a WWW object and create the XmlTextReader with a StringReader containing the data of the loaded WWW object. It’s clearly reading the file, because the length of the While loop corresponds to how many lines are in the XML file (minus 1)…

Is there something obvious I’m doing wrong? Am I not converting the mono strings into javscript strings, or something?

Thank you!

Hello,
“ReadString()” method is designed to read text nodes (like some text), but your XML does not contain such nodes, so just newline characters are printed. Check some XmlTextReader how-to samples on internet (like: Reading and Writing XML in C#).

Oh shoot, thank you. That makes sense, I was afraid it was something obvious like that. Thank you for the link!