[xml] Remove First Two Header Nodes from Xml Doc



Hi,

I am using LibXML2 to generate the xml document which looks like below:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE RequestMessage SYSTEM "RequestMessage.dtd">
<RequestMessage>
    <Header>
        <RequestID>001</RequestID>      
    </Header>
    <Body>
        <ServiceID>678</Service>
    </Body>
</RequestMessage>

Using the following code:

    xmlDocPtr doc = NULL;       /* document pointer */
    xmlNodePtr root_node = NULL, headerNode = NULL, ServiceNode = NULL, BodyNode = NULL;/* node pointers */
    xmlDtdPtr dtd = NULL;       /* DTD pointer */   
    LIBXML_TEST_VERSION;  
    doc = xmlNewDoc(BAD_CAST " 1.0");  
    root_node = xmlNewNode(NULL, BAD_CAST "RequestMessage");  
    xmlDocSetRootElement(doc, root_node);
    dtd = xmlCreateIntSubset(doc, BAD_CAST "RequestMessage", NULL, BAD_CAST " RequestMessage.dtd");
    headerNode = xmlNewChild(root_node, NULL, BAD_CAST "Header",NULL);
    xmlNewChild(headerNode, NULL, BAD_CAST "RequestID", BAD_CAST "001");
    ................................
    ................................

Now what I wanted to do is to remove the first two tags of the xml document which are hightlighted below. i.e.
<?xml version=" 1.0" encoding="utf-8"?>
<!DOCTYPE RequestMessage SYSTEM "RequestMessage.dtd">

So what changes are required in the above mentioned code to generate the xml document which would be like.
<RequestMessage>
    <Header>
        <RequestID>001</RequestID>      
    </Header>
    <Body>
        <ServiceID>678</Service>
    </Body>
</RequestMessage>

Regards,

Ahmad Jalil Qarshi


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]