Menu

Name of a node ??

2003-10-17
2013-05-20
  • Dennis Kempin

    Dennis Kempin - 2003-10-17

    Hi,
    How do i get the name of a TiXmlNode ?

    i.e. <test attr="bla" />

    how do i get the name of this tag ? I can search for tagnames, but i dont know how to get the name, if im iterating the nodes.

     
    • Dennis Kempin

      Dennis Kempin - 2003-10-17

      oh ive found the function. sorry.

       
      • wakewakeup

        wakewakeup - 2007-11-30

        Could you tell me the function? I don't found it :(

         
        • Dr.Joyntz

          Dr.Joyntz - 2007-11-30

          string name;
                  //LOADING XML FILE
              TiXmlDocument doc(file);
              doc.LoadFile();

              //IF NOT LOADED, PRINT ERROR
              if(!doc.LoadFile())
              {
                  cout<< "Error while loading file:\n", doc.ErrorDesc();
              }

              //FIND THE ROOT
              TiXmlElement *root = doc.RootElement();   
              dataset=root->Attribute("name");

                  //FOR-LOOP FOR GOING THROUGH THE XML ELEMENTS AND TAKING OUT ITS ATTRIBUTES
              for( TiXmlElement* elementElement = root->FirstChildElement("element"); elementElement; elementElement = elementElement->NextSiblingElement("element") )
              {
                          //catch from every element the name
                  name = elementElement->Attribute("name");
          }

          or what do you mean???
          my xml look like:

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE data-set SYSTEM "PDF.dtd" >
          <data-set name="PDF">
            <element vr="DATE" len="8" name="Date"></element>
            <element vr="STRING" len="6" name="Title"></element>
            <element vr="STRING" len="6" name="Author"></element>
          </data-set>

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.