473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Parsing XML into a Perl structure

Hi am XML newbie

This is the XML that is returned from a distant server, I can process
it with standard Perl to get the data I want, but I know I ought to be
able to use a Perl Module such as XML::Simple to dump into a Perl
structure automatically, except I can't get it to work.

My xml data is in

$xml= $ua->request($req)->as_string;

can anyone help?

<?xml version="1.0" encoding="utf-8"?>
<ServerTxnResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.zzzyyyxxx.com">
<StdResponse>
<Ad1AvsResult />
<CvcResult />
<AuthResult>6</AuthResult>
<AuthCode>789DE</AuthCode>
....
</StdResponse>

--
zzapper

vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"

http://www.rayninfo.co.uk/tips/ vim, zsh & life tips
Jul 20 '05 #1
2 2554
I've used XML::Simple, the only thing I believe I do is remove the
processing instructions which are your 1st 2 directives

<?xml version="1.0" encoding="utf-8"?>
<ServerTxnResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.zzzyyyxxx.com">

use XML::Simple;
my $parser = XML::Simple->new();
my $doc = $parser->XMLin(.....something like that,

the XML::Simple documentation is.
On 29 Sep 2004 14:31:24 -0700, da***@tvis.co.uk (zzapper) wrote:
Hi am XML newbie

This is the XML that is returned from a distant server, I can process
it with standard Perl to get the data I want, but I know I ought to be
able to use a Perl Module such as XML::Simple to dump into a Perl
structure automatically, except I can't get it to work.

My xml data is in

$xml= $ua->request($req)->as_string;

can anyone help?

<?xml version="1.0" encoding="utf-8"?>
<ServerTxnResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.zzzyyyxxx.com">
<StdResponse>
<Ad1AvsResult />
<CvcResult />
<AuthResult>6</AuthResult>
<AuthCode>789DE</AuthCode>
....
</StdResponse>


Jul 20 '05 #2
Mike H <mr********@earthink.net> wrote in message news:<qh********************************@4ax.com>. ..
I've used XML::Simple, the only thing I believe I do is remove the
processing instructions which are your 1st 2 directives

<?xml version="1.0" encoding="utf-8"?>
<ServerTxnResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.zzzyyyxxx.com">

use XML::Simple;
my $parser = XML::Simple->new();
my $doc = $parser->XMLin(.....something like that,

the XML::Simple documentation is.
On 29 Sep 2004 14:31:24 -0700, da***@tvis.co.uk (zzapper) wrote:
Hi am XML newbie

This is the XML that is returned from a distant server, I can process
it with standard Perl to get the data I want, but I know I ought to be
able to use a Perl Module such as XML::Simple to dump into a Perl
structure automatically, except I can't get it to work.

My xml data is in

$xml= $ua->request($req)->as_string;

can anyone help?

<?xml version="1.0" encoding="utf-8"?>
<ServerTxnResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.zzzyyyxxx.com">
<StdResponse>
<Ad1AvsResult />
<CvcResult />
<AuthResult>6</AuthResult>
<AuthCode>789DE</AuthCode>
....
</StdResponse>

Mike
With help from you I've succeeded with (it's the parameters for xmlin
which are crucial:-

$xml= $ua->request($req)->content;

my $parser = XML::Simple->new();
my $doc = $parser->XMLin($xml, forcearray => 1, keyattr => list);

print Dumper $doc;

--
zzapper

vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"

http://www.rayninfo.co.uk/tips/ vim, zsh & life tips
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott | last post by:
I am new to perl, and have not found any good examples of parsing to help me out. I have a text file that I am reading into an array that has to be parsed out and put into another file. I have not...
4
by: Earl | last post by:
I'm curious if there are others who have a better method of accepting/parsing phone numbers. I've used a couple of different techniques that are functional but I can't really say that I'm totally...
8
by: Jean-Marie Vaneskahian | last post by:
Reading - Parsing Records From An LDAP LDIF File In .Net? I am in need of a .Net class that will allow for the parsing of a LDAP LDIF file. An LDIF file is the standard format for representing...
1
by: Robert Neville | last post by:
Basically, I want to create a table in html, xml, or xslt; with any number of regular expressions; a script (Perl or Python) which reads each table row (regex and replacement); and performs the...
4
by: R Wood | last post by:
Greetings - A recent Perl experiment hasn't turned out so well, which has piqued my interest in Python. The project is this: take a Vcard file exported from Apple's Addressbook and use a...
1
by: worlman385 | last post by:
I need to parse the following HTML page and extract TV listing data using VC++ http://tvlistings.zap2it.com/tvlistings/ZCGrid.do any good way to extract the data? is easy for VC++ to call...
3
by: codemannh | last post by:
I have been trying to figure out the best way to parse some chunks of html code that contain tables. I've been trying to do this with HTML::Parser and HTML::TokeParser and HTML::TokeParser::Simple,...
0
by: HalfCoded | last post by:
hi everyone, I am kind of stuck and therefore would really appreciate some clues: I actually have to run a script which has to compare two elements from two different files which are a blast...
1
by: andrewwan1980 | last post by:
I need help in parsing unicode webpages & downloading jpeg image files via Perl scripts. I read http://www.cs.utk.edu/cs594ipm/perl/crawltut.html about using LWP or HTTP or get($url) functions &...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.