To be able to save the document for usage after you have deleted the parser I suggest that you use the XercesDOMParser object (it is part of the idom implementation). Use it to parse the document as usual, then do an adoptDocument methodcall on the parser to get a DOMDocument pointer that is not deleted when the parserinstance is destroyed (normally the DOMDocument is owned by the parser and is deleted when the parser dies).
Then use the returned documentpointer as described below. And remember: (warning for parrot-like repitition) - You need a grammar (DTD or Schema) describing the xml document. - The attribute containing the error number must be declared as an ID attribute in the grammar. - In the XML file (containing error info) the ID attributes must be names. (just put an undercore infront of the number) - You will need to parse with validation ON to create ID attribute nodes (And be able to use the getElementById method) and... do not forget to delete the document when you are finished with it. Good luck / Erik -----Original Message----- From: Jesse Pelton [mailto:[EMAIL PROTECTED]] Sent: den 10 december 2002 18:54 To: '[EMAIL PROTECTED]' Subject: RE: question getElementById() is a member of DOMDocument. If you're using a DOM parser (such as DOMBuilder, as demonstrated in the DOMCount sample app), the parse call will return a pointer to the DOMDocument. An excerpt from DOMCount.cpp follows: // Instantiate the DOM parser. static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull }; DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(gLS); DOMBuilder *parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYN CHRONOUS, 0); : : DOMDocument *doc = 0; try { // reset document pool parser->resetDocumentPool(); doc = parser->parseURI(xmlFile); } : : Once you've got the doc, you can look up the element and manipulate it. Something like the following should work (I've cheated a bit on the string constants in the interest of readability): XMLCh * elementId = L"my_id"; DOMElement * element = doc->getElementById(elementId); if (element) { XMLCh * attributeName = L"my_att_name"; XMLCh * attributeValue = element->getAttribute(attributeName); } If I understand the problem, you'll set elementId to something based on an error number, and attributeName will be a constant of your choosing. You may want to consider storing the error text in the element content rather than an attribute. I think that's an aesthetic choice in this case. It's somewhat easier to get attribute text, though. -----Original Message----- From: Leitner, Sarah M. [Contractor] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 10, 2002 10:37 AM To: '[EMAIL PROTECTED]' Cc: '[EMAIL PROTECTED]' Subject: question On the response from Erik and subsequent emails, I was told to use the GetElementByID() methodcall. I am having trouble figuring how to use this call. What do I instantiate to get to it? Can someone give me some sample code? How do I use GetAttribute (below)? This was the problem (sorry, the original email is downloaded in my windows partition): I need to assign a number or letter code to each error message that can occur, then store the text of the messages in an XML doc. What is the best way to do this? It was suggested to Parse the error description doc with DOM and save the document for error lookups (I know how to parse, do I have to do anything special to save it?). Then do a GetElementByID() methodcall supplying the error number. Then I do a GetAttribute to get the error message in english. Thanks much for all of your help. Sarah --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]