I've tried to get started using xerces C++ several times, and hit the same 
stumbling block.  I do not understand the strings and how I am supposed to 
use them.  I can stab in the dark and hope I get it right, but that seems 
like a sure road to disaster.  All I want is a way to interface with the DOM 
so that what I get for a returned string is std::string, and what I give is 
std::string.  I'm not sure when, if and where I need to release data.

I believe it is correct that I should do something like:

std::string getTagName(const XERCES_CPP_NAMESPACE::DOMElement* e) {
  if(!e) throw exceptions::NullPointer("...");
  char* tmp = XMLString::transcode(const XMLCh *const e->getTagName());
  std::string ret(tmp);
  XMLString::release(tmp);
  return ret;
}

DOMElement* createElement(DOMDocument* d, const char* tagName) {
  if(!d) throw exceptions::NullPointer("...");
  XMLCh *const tmp = XMLString::transcode(tagName);
  DOMElement* ret = DOMDocument::createElement(const XMLCh *tagName);
  XMLString::release(tmp);
  return ret;
}

I suspect I can write better gluecode if I have the basic concept of what I 
need to do.  The above seems inelegant.  Is this manual allocation and 
deallocation the best way to do things?  Is it even correct? 

Is there any particular reason Xerces C++ only deals in pointers, rather than 
values?  If I could get something like an XMLString returned I could use RAII 
- assuming it called realease when its destructor is called.

STH

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

Reply via email to