473,569 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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"?>
<ServerTxnRespo nse xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.zzzyyyxxx.c om">
<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 2560
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"?>
<ServerTxnRespo nse xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.zzzyyyxxx.c om">

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

the XML::Simple documentation is.
On 29 Sep 2004 14:31:24 -0700, da***@tvis.co.u k (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"?>
<ServerTxnResp onse xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="htt p://www.w3.org/2001/XMLSchema-instance"
xmlns="https ://www.zzzyyyxxx.c om">
<StdResponse>
<Ad1AvsResult />
<CvcResult />
<AuthResult>6 </AuthResult>
<AuthCode>789DE </AuthCode>
....
</StdResponse>


Jul 20 '05 #2
Mike H <mr********@ear think.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"?>
<ServerTxnRespo nse xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.zzzyyyxxx.c om">

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

the XML::Simple documentation is.
On 29 Sep 2004 14:31:24 -0700, da***@tvis.co.u k (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"?>
<ServerTxnResp onse xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="htt p://www.w3.org/2001/XMLSchema-instance"
xmlns="https ://www.zzzyyyxxx.c om">
<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
17518
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 found any good examples of this. Does anyone know of any? For example the text file looks like this... 900002 "Test,Test" 1/1/2004 ...
4
5247
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 happy with either. 1. My first technique was to restrict the users to entries that could only be 3 character, 3 characters, 4 character (area...
8
4422
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 LDAP objects. I need to be able to read the records from an LDIF file into ..Net. There exists a Perl module that will do exactly this called...
1
1756
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 replacement on any file name, folder, or text file (e.g. css, php, html). For example, I often rename my mp3 (files); the folder holding the mp3...
4
3917
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 language that is good at parsing text to convert it into a mutt alias file. There are better ways to use Mutt with Mac's addressbook, but I want to be...
1
2479
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 PERL script and do some regular expression? since the HTML page is not XML well formed, I cannot use a XML parser
3
2453
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, but I just can't seem to get everything working the way I want. The chunks are from a standard template so there is some structure to the data, but it...
0
1322
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 file and a cdf file I need also to keep the data structure For this I chose the following strategy: -dumping the files into two arrays -doing a...
1
2814
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 & libraries. But the content returned is always garbled. I have used get($url) on a non-unicode webpage and the content is returned in perfect ascii. ...
0
7614
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7676
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.