Hi Stephen,

At 04.32 04/10/2006 -0500, Stephen Torri wrote:
The following code causes the STL std::string class to throw a
std::logic_error when I try to initialize a std::string with the results
of XMLString::transcode.

    std::string form_str = XMLString::transcode ( elem_ptr->getNodeValue() );

elem_ptr is a DOMElement*.

Is there an accepted way to convert to a std::string?

The code you wrote would work, but not on DOMElement nodes; getNodeValue in that case returns NULL, so XMLString::transcode returns NULL, and std::string doesn't like that. If the element has only one child node you can use elem_ptr->getFirstChild()->getNodeValue(), or even use elem_ptr->getTextContent() [note: this will raise your memory consumption]

Alberto

Reply via email to