Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi monks, I have one string with xml data,I am processing that sting using XML::Simple module and template toolkit process. By using PDF latex I am converting it into pdf. But my problem is I have some repeated information in XML format.so its also repeating in pdf.How to remove this information.My data look like this.

<specification> <details> <name>johan</name> <address>Langgt 23</address> ---more info--- </details> <details> <name>venu</name> <address>storgatan 27</address> ---more info--- </details> <details> <name>kent</name> <address>nygatan 46</address> ---more info---- </details> <details> <name>johan</name> <branch>ece</branch> ---more info-- </details> </specification>

In the above xml file name johan repeated in two nodes and in frist node He having the address details, In the repeated node he having some other details but I need only nodes that contain address information . If any nodes don't have address nodes then remove entire node information.I am new to perl language how to find the nodes that don't have address information and how to delete that node. please help me.

Some body suggested XML::simple automatically deletes repeated information with some specific configuration but I cant found in that module.

please help me i am working from last 10 days on this task but I am unable to remove such information, Any help appreciated.

I am processing like that

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; use XML::Simple; use XML::Fast; use Template; my $data="some xml data"; my $xml = new XML::Simple; my $data = $xml->XMLin("$data", ForceArray =>['name','address'],); #print Dumper($data); my $template = Template->new(); my $filename = 'output1.tex'; $template->process(\*DATA, $data, $filename) || die "Template process failed: ", $template->error(), "\n"; system( "pdflatex $filename" ); __DATA__ \documentclass[a4paper,leqno,twoside]{article} \usepackage[latin1]{inputenc} \usepackage[english]{babel} \usepackage{multirow} \renewcommand{\familydefault}{\sfdefault} \usepackage{color} \usepackage[colorlinks=true]{hyperref} \begin{document} [% FOREACH st IN details %] [% st.name %] [%st.address%] ---more info--- [%END%]

any help appreciated

Thanks in advance


In reply to help need when processing xml using perl by veerubiji

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-19 19:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found