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

Re: Determine the structure of an XML document

by kcott (Archbishop)
on May 13, 2014 at 03:04 UTC ( [id://1085859]=note: print w/replies, xml ) Need Help??


in reply to Determine the structure of an XML document

G'day bangor,

While I'm not a huge fan of XML::Simple for general XML work, it may suit your needs with minimal coding such as this:

use Data::Dump; use XML::Simple; dd XMLin('document.xml');

Here's an example of the output using the sample XML you provided.

{ latin_name => "Fraxinus Excelsior", name => "Ash", uses => { use => [ { description => "Furniture making" }, { description => "Firewood" }, ], }, }

That seems fairly close to the "simple text representation' you're after. See the XML::Simple documentation for how to tweak that output.

Just for completeness, I generated that output using a here-doc with the XML you posted. The code's in the spoiler for those interested.

-- Ken

Replies are listed 'Best First'.
Re^2: Determine the structure of an XML document
by bangor (Monk) on May 13, 2014 at 03:21 UTC
    Thanks Ken, that output structure will definitely help me with the processing stage.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1085859]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-20 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found