Hi,

 

I would like to remove all of person1 and its child tags below.

 

 

- <<Contacts>

- <  <Person1>

  <           <ContactType>Partner</ContactType>

 <FirstName>y</FirstName>

         <LastName>y</LastName>

      <Salutation>y</Salutation>

         <Title>y</Title>

      <EmailAddress>y</EmailAddress>

      <TelephoneNumber>y</TelephoneNumber>

      <PreferredLanguage>y</PreferredLanguage>

         <Availability>y</Availability>

            <Property name="value">y</Property>

 </Person1>

  <Person2>

  <ContactType>Partner1</ContactType>

  <FirstName>x</FirstName>

  <LastName>x</LastName>

  <Salutation>x</Salutation>

  <Title>x</Title>

  <EmailAddress>x</EmailAddress>

  <TelephoneNumber>x</TelephoneNumber>

  <PreferredLanguage>x</PreferredLanguage>

  <Availability>x</Availability>

  <Property name="value">x</Property>

  </Person2>

  </Contacts>

 

 

But this code does not do this.

 

xercesc::DOMNode* node = findNode(szContactType, "ContactType");    // this is the node I want to delete

 

 

DOMNode* current = node->getFirstChild();

while (current != NULL)

{

      node->removeChild(current);

      current = node->getFirstChild();

}

 

 

But after the code is run the node and children are still in the XML file.

 

I would really appreciate some help, or even tell me if I am doing things correctly.

 

Thanks,

Enda

 


From: Mannion, Enda
Sent: 08 June 2006 10:00
To: c-dev@xerces.apache.org
Subject: RE: removeChild not working

 

Here is some more code using removeChild() that does not work for me.

 

 

xercesc::DOMNode* node = findNode(szContactType, "ContactType");

char* nodeName = XMLString::transcode(node->getNodeName());

 

 

DOMNode* current = node->getFirstChild();

while (current != NULL)

{

      char* nodeNa = XMLString::transcode(current->getNodeName());

      node->removeChild(current);

      current = node->getFirstChild();

}

 

I am currently using xerces 2_4, I have to remain using this version for a while, but I presume removeChild() worked in 2_4.

 

 

Any Ideas?

 

Enda

 


From: Mannion, Enda
Sent: 07 June 2006 20:40
To: c-dev@xerces.apache.org
Subject: removeChild not working

 

I want to remove the node below called outerNode but it is not working, any ideas.

 

 

xercesc::DOMNode* docNode = xmlDoc->getDocumentElement();

 

DOMNodeList* list = docNode->getChildNodes();

DOMNode* outerNode = NULL;

 

outerNode = list->item(i);

 

docNode->removeChild(outerNode);

 

 

Any ideas why?

Enda

 

 

 

Reply via email to