Hi,
What is the best way to set a string attribute of a class from a XML Tree:
And the best way to set a double value
Here I'm just interest in the XMLString::transcode and XMLString::release
mechanism

Example of what I planned to do:
<node1>
    <node>value</node> 
    <double>1.123</double>
</node1>

class A
{
   string strvalue;
   float fvalue;
}

(...)
DOMNode* node1 = node->getFirstChild();
while(node1)
{
    char* temp1 =XMLString::transcode(node->getNodeName()); 
    if (strcmp(temp1,"node1") == 0)
    {
        DOMNode* node2 = node1->getFirstChild(); 
        while (node2)
        {
              char* temp2 = XMLString::transcode(node2->getNodeName());
              if (strcmp(temp2,"node") == 0)
              {
                    DOMNode* node3 = node2->getFirstChild();
                    A.strvalue = XMLString::transcode(node3->getNodeValue());
                    //Should I do the release in the destructor of A?
              }
              else if (strcmp(temp2,"double") == 0)
              {
                    DOMNode* node3 = node2->getFirstChild();
                    char* temp3 =
XMLString::transcode(node3->getNodeValue());
                    A.fvalue = atof(temp3);
                    XMLString::release(&temp3);
              }
              XMLString::release(&temp2);
              node2 = node2->getNextSibling();
        }
    }
    XMLString::release(&temp1);
    node1 = node1->getNextSibling();
}
(...)

Is it the best way?
Regards

-- 
View this message in context: 
http://www.nabble.com/XMLString%3A%3Atranscode-and-XMLString%3A%3Arelease-mechanism-tp20380344p20380344.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to