Advertisement

03.29.2008 at 10:42PM PDT, ID: 23280360 | Points: 500
[x]
Attachment Details

Modifying the XML - Deleting certain nodes in a give xml

Asked by anagm in Extensible Markup Language (XML), Extensible HTML (XHTML), Extensible Stylesheet Language Transformation (XSLT)

Hello,

This is the given xml:
"<EmailList>
   <Email>
    <EmailAddress>first@test.com</EmailAddress>
  </Email>
  <Email>
    <EmailAddress>second@test.com</EmailAddress>
  </Email>
  <Email>
    <EmailAddress>third@test.com</EmailAddress>
  </Email>
  <Email>
    <EmailAddress/>
  </Email>
  <Email>
    <EmailAddress/>
  </Email>
  <Email>
    <EmailAddress/>
  </Email>
  <Email>
    <EmailAddress/>
  </Email>
  <Email>
    <EmailAddress/>
  </Email>
  <Email>
    <EmailAddress/>
  </Email>
<Email>
    <EmailAddress/>
  </Email>
<EmailList>"


I want to delete the 'Email' node in the above xml and modify that as below:
"<EmailList>
      <EmailAddress>first@test.com</EmailAddress>
      <EmailAddress>second@test.com</EmailAddress>
      <EmailAddress>third@test.com</EmailAddress>
      <EmailAddress/>
      <EmailAddress/>
      <EmailAddress/>
      <EmailAddress/>
      <EmailAddress/>
     <EmailAddress/>
      <EmailAddress/>
 <EmailList>"

i have the above xml in a string, that is lstrSendingXml.
i am triying as below:

XMLDoc.LoadXml(lstrSendingXml)
XMLNode = RewardDoc.SelectSingleNode("EmailList/Email")

Any help would be greatly appreciated.


Start Free Trial
[+][-]03.30.2008 at 02:16PM PDT, ID: 21241981

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.30.2008 at 06:51PM PDT, ID: 21242737

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628