in reply to Parsing xml

Your XML is not well formed - the get_course_grades tag is not closed.

Don't use XML::Simple. Its documentation itself tells you you shouldn't.

You can use XML::LibXML instead.

#!/usr/bin/perl use warnings; use strict; use XML::LibXML; my $xml = 'XML::LibXML'->load_xml(location => shift); for my $username ($xml->findnodes('//username')) { print $username->textContent, "\n"; }

I usually use XML::XSH2, which is a wrapper around XML::LibXML. It simplifies the above code to

open file.xml ; for //username echo (.) ;

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Parsing xml
by alexsc01 (Novice) on Feb 19, 2016 at 11:55 UTC
    HI, Thanks I used this and it worked fine.
    my $xml = 'XML::LibXML'->load_xml(string => $response_xml); for my $username ($xml->findnodes('//username')) { print $username->textContent, "\n"; }
    Yes the xml was badly formed I copied a long string and just pasted a few rows as an example. Thanks for your help.