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.