1

I'm using tinyxml2 in my after effects plugin to parse xml files. But I can't seem to get the XMLDocument object to load my xml file. The "loadFile" function can read the whole content of my file. but when I call the "toText" method, it returns null. Here's a snippet of my code.

tinyxml2::XMLDocument   envXml;
envXml.LoadFile("D:/~env.xml");

XMLText *text = envXml.ToText();//return null

XMLNode *srcChild = envXml.LastChild();
XMLElement *srcElement = srcChild->ToElement();// crash

here's my xml file content:

<xml>
    <rs_tpl>E:/RenderSettingTemplate.aep
        <t>test</t>
    </rs_tpl>
    <logo_path>E:/logo.png</logo_path>
    <src>E:/wed_01_Mamamiya_bbb/wed_01_Mamamiya_bbb.aep</src>
    <dst>E:/66435/~out.aep</dst>
    <out_path>E:/66435/out/SD.mp4</out_path>
    <out_comp>SD</out_comp>
</xml>

What I'm doing wrong?

mpromonet
  • 11,326
  • 43
  • 62
  • 91
  • Do `LoadFile` return a status? Do you check that status? – Some programmer dude Jul 26 '14 at 09:21
  • Hi, the loadFile return a _errotID of 175636736, well sometime it return _errotID of 256 – zhiqiang-li Jul 26 '14 at 09:28
  • I suggest you [read the documentation](http://www.grinninglizard.com/tinyxml2docs/index.html) because that means it fails (one way or another) to load the file. Using the document if the loading fails probably leads to undefined behavior. – Some programmer dude Jul 26 '14 at 09:31
  • according to http://grinninglizard.com/tinyxml2docs/classtinyxml2_1_1_x_m_l_document.html#a2ebd4647a8af5fc6831b294ac26a150a it should be XML_NO_ERROR (0) in the good case; you can't just step onto it and process it the way you do if there obviously is an error on load and expect it works. – Solkar Jul 26 '14 at 09:32
  • Thank you guys for your help. I know I'm not supposed to go ahead just request for data when there's something wrong during loading the xml file. But I can't find out what cause the loading error. I added a break point at the "loadFile" line, and found out that it reads the content of my xml file correctly. I even tried to use the "Parse" method instead of "loadFile" to initialize the XMLDocument, it didn't work either. – zhiqiang-li Jul 26 '14 at 09:53
  • I have the same issue. I think the library is maybe just crap. – dgrat Mar 09 '20 at 14:32

0 Answers0