XML problem but everything looks good

Hi All, @stevebaer, @clement,

I’m trying to read data from an xml file following the example found on Rhinopython forum:

import clr  
import System.Xml

def XMLTest():
    filename = r"d:\rosso.xml"  
    xmldoc = System.Xml.XmlDocument()  
    items = xmldoc.SelectNodes("data/items/item")  
    for item in items:  
        print item.InnerText

if __name__=="__main__":

at the execution of the line:
The script interrupt saying there’s a problem at row 1, position 44.
Of course rosso.xml exist at that position and it’s an xml file, could be because it’s a V-Ray material so without the standard declaration on the head?

here the source file: rosso.xml (4.0 KB)
and the original script: readxml_prova.py (339 Bytes)

Could you help me undertand what’s wrong?

Have you even seen the inside of the XML file you attached? It is full of binary stuff, not a plain text file!
It is definitely not an XML file as XmlDocument would understand…

Hi Riccardo,

yes, i guess the error message means that the xml file you´re trying to read is not having the proper header and therefore the encoding is missing. Look inside the file !

I´ve tried it in a xml text editor and Dreamweaver to check. Your script runs ok here if i use a different xml file.


Thanks Guys!
This was exactly my suspect.

I’ll try to do it in another way.


Yes… Feel stupid, I was looking to the code not taking care enough of the file !!!
With a Proper xml works fine.