Menu

Problem with Attribute() ??

2005-04-12
2013-05-20
  • Stuart Grassie

    Stuart Grassie - 2005-04-12

    Hello,
    I'm trying to use tinyxml to parse an xml file and load data into my project (and eventually save it). I want to use the value of the id of the attribute in a treenode. So far I have this:

    TiXmlDocument     *xmlDoc = new TiXmlDocument("baseline.xml");
    xmlDoc->LoadFile();

    TiXmlElement *xClient = 0;
    xClient = xmlDoc->FirstChildElement("client");

    //add to treenode, under baselines node
    Node1 = TreeView->Items->Item[1]; //second node in tree view
    TreeView->Items->AddChild(Node1,xClient->Attribute("id"));

    but when I compile the app (using borland c++ builder 6 enterprise), I get an error that says:

    Method called on invalid object
    - attempt to access 104 byte(s) at 0x0000000
    - 0x0000110C
    - TiXmlElement::Attribute()
    - TbaseLiner::TbaseLiner(class:: TComponent *)
    - 0400F59A4
    - WinMain(void*,void *,char*,int)
    - 0x3267E52F

    As far as I can see, what I'm doing should work? Anyone have any suggestions?

     
    • Stuart Grassie

      Stuart Grassie - 2005-04-13

      Ok, after some reading I've managed to do what I wanted another way, but still, I'm sure what I did earlier should have worked?

       
    • B Sizer

      B Sizer - 2005-04-13

      I think the error is pretty clear in this case. Take a look at the return value of xmlDoc->FirstChildElement("client");

      What does your XML data look like?

       

Log in to post a comment.