Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??


I have an XML file that I am trying to strip back into plain text... Listed Below is an excerpt of the XML data...

I am trying to use something like s/\<.+\>//; to remove all of the the text contained within the < > brackets... The file does not seem to open correctly...

Any advice...?

<?xml version="1.0" encoding="UTF-16"?> <joblog><job_log_version version="1.0"/> <header><filler> ====================================================================== </filler><server>Job server: computername </server><name>Job name: computername - Inc </name><start_time>Job started: Monday, December 27, 2004 at 2:53:38 PM </start_time><type>Job type: Backup </type><log_name>Job Log: BEX00164.xml </log_name><filler> ====================================================================== </filler></header><media_drive_and_media_info> Drive and media information from media mount: <robotic_library_name>Robotic Library Name: COMPAQ 1 </robotic_library_name><drive_name>Drive Name: COMPAQ 1 </drive_name><slot>Slot: 1 </slot><media_label>Media Label: DSW000 </media_label><media_guid>Media GUID: {431B03DE-1C49-11D4-B21C-00508BCA3A68} </media_guid><media_overwrite_date>Overwrite Protected Until: 1/30/2005 3:14:41 AM </media_overwrite_date><media_append_date>Appendable Until: 12/31/9999 12:00:00 AM </media_append_date><media_set_target>Targeted Media Set Name: Daily </media_set_target></media_drive_and_media_info><backup><filler> ====================================================================== </filler><title>Job Operation - Backup </title><append_or_overwrite>Media operation - append. </append_or_overwrite><compression>Hardware compression enabled. </compression><filler>

I want the output to look like this

====================================================================== Job server: computername Job name: computername - Inc Job started: Monday, December 27, 2004 at 2:53:38 PM Job type: Backup Job Log: BEX00164.xml ====================================================================== Drive and media information from media mount: Robotic Library Name: COMPAQ 1 Drive Name: COMPAQ 1 Slot: 1 Media Label: DSW000 Media GUID: {431B03DE-1C49-11D4-B21C-00508BCA3A68} Overwrite Protected Until: 1/30/2005 3:14:41 AM Appendable Until: 12/31/9999 12:00:00 AM Targeted Media Set Name: Daily ====================================================================== Job Operation - Backup Media operation - append. Hardware compression enabled. ======================================================================

Thank you for any help...

Dozens of br tags throughout input/output examples replaced by a set of code tags, to eliminate issues with long-line horizontal scrolling, by davido.
Edit by castaway - HTML entities turned back into literal characters, to make sense with code tags

In reply to how to strip XML into Plain Text file by dbrock

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?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2023-02-05 00:53 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (31 votes). Check out past polls.