How to remove empty element from xml file

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi

How do I remove the empty elemet (coloured in blue) from the xml below and save as xml file only with the element has value?? .I pasted only a portion of xml.

I need a CODE to iterate through the document and remove all empty elements and leave only the START ELEMENT and ELEMENT with values

<font style="font-weight: bold;" size="5 FROM </font><font size="5 <font size="2 (the xml below)</font></font>
<div class="e
<div class="c" style="margin-left: 1em; text-indent: -2em; <a class="b # - <span class="m <font size="2 <</font><font size="2 <span class="t LeaseDetails<span class="m ></font>

<div class="e
<div style="margin-left: 1em; text-indent: -2em; <font size="2 <span class="b <span class="m <<span class="t <LeaseType <span class="m ><span class="m <span class="m </font>

<div class="e
<div style="margin-left: 1em; text-indent: -2em; <font size="2 <span class="b <span class="m <<span class="t <StartDate<span class="m >2005-05-05<span class="m <<span class="t /StartDate<span class="m ></font>

<div class="e
<div style="margin-left: 1em; text-indent: -2em; <font size="2 <span class="b <span class="m <<span class="t <EndDate<span class="m ><span class="m <span class="m 2005-05-05<span class="m <span class="m </<span class="t EndDate<span class="m ></font>

<div class="e
<div class="c" style="margin-left: 1em; text-indent: -2em; <font size="2 <a class="b # - <span class="m <<span class="t StartingRent<span class="m ></font>

<div class="e
<div style="margin-left: 1em; text-indent: -2em; <font size="2 <span class="b <span class="m <<span class="t <RentPayable<span class="m ><span class="tx 0.00<span class="m </<span class="t RentPayable<span class="m ></font>
<div class="e
<div style="margin-left: 1em; text-indent: -2em; <font size="2 <span class="b <span class="m <span style="color: rgb(0, 0, 255); <<span style="color: rgb(0, 0, 255);" class="t <LaterRentKnown<span style="color: rgb(0, 0, 255); <span style="color: rgb(0, 0, 255);" class="m /></font>
<font size="2 <span class="b <span class="m </<span class="t StartingRent<span class="m >
<span class="m </<span class="t LeaseType><span class="m </font>
<font size="2 <span class="b <span class="m </<span class="t LeaseDetails</font><span class="m <font size="2 ></font>

<span style="font-weight: bold; To<font style="font-weight: bold;" size="5 </font><font size="5 <font size="2 (the xml below)

</font></font><span class="m <font size="2 <</font><font size="2 <span class="t LeaseDetails<span class="m ></font>

<div class="e
<div style="margin-left: 1em; text-indent: -2em; <font size="2 <span class="b <span class="m <<span class="t <LeaseType <span class="m ><span class="m <span class="m </font>

<div class="e
<div style="margin-left: 1em; text-indent: -2em; <font size="2 <span class="b <span class="m <<span class="t <StartDate<span class="m >2005-05-05<span class="m <<span class="t /StartDate<span class="m ></font>

<div class="e
<div style="margin-left: 1em; text-indent: -2em; <font size="2 <span class="b <span class="m <<span class="t <EndDate<span class="m ><span class="m <span class="m 2005-05-05<span class="m <span class="m </<span class="t EndDate<span class="m ></font>

<div class="e
<div class="c" style="margin-left: 1em; text-indent: -2em; <font size="2 <a class="b EditPost.aspx?PostID=792470&SiteID=1&ReturnUrl=%2fMSDN%2fShowPost.aspx%3fPostID%3d792470%26SiteID%3d1%26mode%3d1# - <span class="m <<span class="t StartingRent<span class="m ></font>

<div class="e
<div style="margin-left: 1em; text-indent: -2em; <font size="2 <span class="b <span class="m <<span class="t <RentPayable<span class="m ><span class="tx 0.00<span class="m </<span class="t RentPayable<span class="m ></font>

<font size="2 <span class="b <span class="m </<span class="t StartingRent<span class="m >
<span class="m </<span class="t LeaseType><span class="m </font>
<font size="2 <span class="b <span class="m </<span class="t LeaseDetails</font><span class="m <font size="2 ></font>



View the full article
 
Back
Top