CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Removing null tags from XML file in perl

 



aditya83
New User

Mar 9, 2008, 3:58 AM

Post #1 of 1 (362 views)
Removing null tags from XML file in perl Can't Post

Hi,

We are trying to create a XML extract(with the help of another tool) and then send it to a portal. How can i remove the null tags and the entire null hierarchy from the xml file? I am giving an example of type of null tabs we are getting:
<root>
<level1>
<level2>
</level2>
</level1>
<level1>
<level2>Value</level2>
</level1>
</root>

The output of the script should be
<root>
<level1>
<level2>Value</level2>
</level1>
</root>

I have tried several approaches but the problems i faced were that i was able to traverse to the leaf node ( for valid tags), but was after that there was no way to know whether the immediate parent had a valid value. The output that i got every time was
<root>
<level1>
<level2>Value</level2>

After this i was expecting the closing tags also to come.
Is there a way out to solve this problem(of removing the null hierarchies)?

Thanks
Aditya

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives