XPathEvaluator::initialize();
try {
// theDocmentPtr is the
XalanDocument
DOMDocument* Domdoc = (DOMDocument*)theLiaisonPtr->mapToXercesDocument(theDocumentPtr);
XalanDocument *Xalandoc = theLiaisonPtr->createDocument(Domdoc,false,true);
XalanNode * root_context_node = Xalandoc;
DOMDocument* Domdoc = (DOMDocument*)theLiaisonPtr->mapToXercesDocument(theDocumentPtr);
XalanDocument *Xalandoc = theLiaisonPtr->createDocument(Domdoc,false,true);
XalanNode * root_context_node = Xalandoc;
XalanElement *namespace_node
= Xalandoc->getDocumentElement();
const XalanDOMString
_expression_("/MAIN/NAME2");
const DOMNode *target= 0;
XPathEvaluator evaluator;
XalanNode* found =
evaluator.selectSingleNode(
(*theDOMSupportPtr),
root_context_node,
_expression_.c_str(),
namespace_node);
if (found) {
root_context_node,
_expression_.c_str(),
namespace_node);
if (found) {
XercesDocumentWrapper
*xerces_document_wrapper
= theLiaisonPtr->mapDocumentToWrapper(Xalandoc);
DOMNode * target =(DOMNode *)
xerces_document_wrapper->mapNode(found);
XMLCh *TagName=XMLString::transcode("HELLO");
DOMNode *ElementNode= Domdoc->createElement(TagName);
XMLCh *TagText=XMLString::transcode("IAMHERE");
DOMText *TextNode= Domdoc->createTextNode(TagText);
ElementNode->appendChild(TextNode);
target->appendChild(ElementNode);
xerces_document_wrapper->rebuildWrapper();
}
}
XMLCh *TagName=XMLString::transcode("HELLO");
DOMNode *ElementNode= Domdoc->createElement(TagName);
XMLCh *TagText=XMLString::transcode("IAMHERE");
DOMText *TextNode= Domdoc->createTextNode(TagText);
ElementNode->appendChild(TextNode);
target->appendChild(ElementNode);
xerces_document_wrapper->rebuildWrapper();
}
}
My INPUT
XML FILE IS............
<MAIN>
<Name>
<Skill>ABC</Skill>
<Level>0TEEE00</Level>
</Name>
<Name2>
<Skill>Jaya</Skill>
<Level>2222</Level>
</Name2>
</MAIN>
<Name>
<Skill>ABC</Skill>
<Level>0TEEE00</Level>
</Name>
<Name2>
<Skill>Jaya</Skill>
<Level>2222</Level>
</Name2>
</MAIN>
If I give a XPATH as "/MAIN/NAME2"
My
OUTPUT XML FILE should be............BUT STRANGELY IT IS NOT WORKING Please
help
<MAIN>
<Name>
<Skill>ABC</Skill>
<Level>0TEEE00</Level>
<Name>
<Skill>ABC</Skill>
<Level>0TEEE00</Level>
</Name>
<Name2>
<Skill>Jaya</Skill>
<Level>2222</Level>
<Name2>
<Skill>Jaya</Skill>
<Level>2222</Level>
<HELLO>IAMHERE</HELLO>
// its not adding
</Name2>
</MAIN>
what could be the problem with the
code ?
I am rebuilding the wrapper. But still
the main Xalandocument is not
affected.
Dave: Could you please help me!
-Thanks
Praveen
Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. |
