Does the XML object actually work?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
lloydwood
Posts: 3
Joined: December 22nd, 2011, 8:59 am

Hello,

I'm trying to read an XML with the XML object but I'm getting unexpected results. I'm using the following code to read in the XML and then create an XML object.

Code: Select all

        function parseXML(path)
        {
            var xml_file = new File(path);
            xml_file.open ("r", "XML");
            var lines = xml_file.read();
            xml_file.close();
            
            return new XML(lines);
        }
That actual XML is very simple and looks like this:

Code: Select all

<RootNode>
      <Project></Project>
</RootNode>
If I run the command:

Code: Select all

xml.RootNode;
according to the docs I should get "Project" back but I get nothing. If I call length() on the returned list I get 0. I tried running the code with a string too instead of reading the file and got the same result. Does this mean the XML object ins't working or is it something I'm doing wrong?
lloydwood
Posts: 3
Joined: December 22nd, 2011, 8:59 am

I've now actually bypassed this and used a command line python script to parse the XML. It gives me more flexibility anyway.
Post Reply