Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6646077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:22:18+00:00 2026-05-26T00:22:18+00:00

I have data dumper outputting a remotely hosted xml file into a local text

  • 0

I have data dumper outputting a remotely hosted xml file into a local text file and I am getting the following info:

$VAR1 = {
    'resource' => {
        '005cd410-41d6-4e3a-a55f-c38732b73a24.xml' => {
            'standard' => 'DITA',
            'area' => 'holding',
            'id' => 'Comp_UKCLRONLINE_UKCLR_2000UKCLR0278',
        },
        '003c2a5e-4af3-4e70-bf8b-382d0b4edda1.xml' => {
            'standard' => 'DITA',
            'area' => 'holding',
            'id' => 'Comp_UKCLRONLINE_UKCLR_2000UKCLR0278',
        },  

etc. What I want to do is work with just one/key and value in each resource. Ie pick out the ID and then create a url from that.

I would normally use a regex on the file and pull the info I need from that but I’m thinking there must be an easier/proper way but can’t think of the right term to use in a search and am therefore not finding it.

Here is the code I am using to write this output to a file:

#-----------------------------------------------
sub request_url {
#-----------------------------------------------
my $useragent = LWP::UserAgent->new;
my $request = HTTP::Request->new( GET => "http://digitalessence.net/resource.xml" );
$resource = $useragent->request( $request );                                            
}


#-----------------------------------------------
sub file_write {
#-----------------------------------------------
open OUT, ">$OUT" or Log_message ("\n$DATE - $TIME - Could not create filelist.doc \t");
Log_message ("\n$DATE - $TIME - Opened the output file");
print OUT Dumper (XML::Simple->new()->XMLin( $resource->content ));
Log_message ("\n$DATE - $TIME - Written the output file");
}

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:22:19+00:00Added an answer on May 26, 2026 at 12:22 am

    Maybe you want to walk the data structure built by XML::Simple.
    Each resource is inside an ARRAYREF you get using the resource key with $doc data structure.

    use XML::Simple;
    use LWP;
    use Data::Dumper;
    
    my $ua = LWP::UserAgent->new;
    my $req = HTTP::Request->new( GET => "http://digitalessence.net/resource.xml" );
    my $res = $ua->request( $req );
    
    my $xs         = XML::Simple->new();
    my $doc        = $xs->XMLin( $res->content );
    
    printf "resources: %s\n", scalar keys %{ $doc->{ resource } };
    
    foreach ( keys %{ $doc->{ resource } } ) {
        printf "resource => %s, id => %s\n", $_, $doc->{ resource }->{ $_ }->{ id };
    }
    

    The output is this:

    resources: 7
    resource => 005cd410-41d6-4e3a-a55f-c38732b73a24.xml, id => Comp_UKCLRONLINE_UKCLR_2000UKCLR0278
    resource => 003c2a5e-4af3-4e70-bf8b-382d0b4edda1.xml, id => Comp_UKCLRONLINE_UKCLR_2002UKCLR0059
    resource => 0033d4d3-c397-471f-8cf5-16fb588b0951.xml, id => Comp_UKCLRONLINE_UKCLR_navParentTopic_67
    resource => 002a770a-db47-41ef-a8bb-0c8aa45a8de5.xml, id => Comp_UKCLRONLINE_UKCLR_navParentTopic_308
    resource => 000fff79-45b8-4ac3-8a57-def971790f16.xml, id => Comp_UKCLRONLINE_UKCLR_2002UKCLR0502
    resource => 00493372-c090-4734-9a50-8f5a06489591.xml, id => Comp_UKCLRONLINE_COMPCS_2010_10_0002
    resource => 004377bf-8e24-4a69-9411-7c6baca80b87.xml, id => Comp_CLJONLINE_CLJ_2002_01_11
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following test code use Data::Dumper; my $hash = { foo =>
I have an object that I printed with Data::Dumper : $VAR1 = { 'record'
I have a Perl script to convert the XML file below into a hash:
I have the following code use strict; use warnings; use Data::Dumper; my $s =
I have the following XML file: <?xml version='1.0'?> <preferences> <font role=console> <fname>Courier</fname> <size>9</size> </font>
I have data from a table in a database (string) that contain text and
I have this piece of script : #!/usr/bin/perl use strict; use warnings; use Data::Dumper;
I have 'Malformed UTF-8 character' error when I'm putting some scalar data in XML::Simple
I have this code #!/usr/bin/perl -w use strict; use URI; use LWP::UserAgent; use Data::Dumper;
I have this script #!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %acc =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.