ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-unix-users
perl-unix-users
Re: [Perl-unix-users] XML Parse Error
by Bill Luebkert other posts by this author
Oct 12 2009 6:52PM messages near this date
[Perl-unix-users] XML Parse Error | [Perl-unix-users] (no subject)
Jonathan Dudson wrote:
>  
>  no element found at line 1, column 0, byte 0:
>  
>  at 
>  /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/XML/Parser.pm 
>  line 187

Run the below code and data and see if you get a different result - if so,
we can talk about versions and platforms etc:

Ran the following script on Perl 5.8 B820:

#!perl --

use strict;
use warnings;
use XML::Parser;
use XML::SimpleObject;
use Data::Dumper; $Data::Dumper::Indent=1; $Data::Dumper::Sortkeys=1;

my $xml_file_path = 'foo.xml';

my $parser = XML::Parser-> new(ErrorContext => 2, Style => "Tree");

# make the xml accessable from OO type calls

my $xmlobj = XML::SimpleObject-> new($parser->parsefile($xml_file_path));

# for every <DataRow>  tag assign it to $objDataBlock

foreach my $objDataBlock ($xmlobj-> child("Report")->children("DataRow")) {
	print Data::Dumper-> Dump([$objDataBlock], [qw($objDataBlock)]);
}

__END__

Got this output:

$objDataBlock = bless( {
   'TelephoneNumber' =>  [
     bless( {
       '_ATTRS' =>  {},
       '_NAME' =>  'TelephoneNumber',
       '_VALUE' =>  '123......'
     }, 'XML::SimpleObject' )
   ],
   '_ATTRS' =>  {},
   '_NAME' =>  'DataRow',
   '_VALUE' =>  '

'
}, 'XML::SimpleObject' );

using your data file:

<Report> 
<DataRow> 
<TelephoneNumber> 123......</TelephoneNumber>
</DataRow> 
</Report> 



_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Jonathan Dudson
Bill Luebkert

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved