Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: Parsing xml using libXML

by Anonymous Monk
on Jul 18, 2013 at 13:58 UTC ( #1045104=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Parsing xml using libXML
in thread Parsing xml using libXML

well Its in my code

Well, it isn't. Your code builds no data structures, it just print stuff. So which is it, data structures, or print stuff, or what?

You say it doesn't print it all, so what would it print, how would the missing look?

Nevermind , https://metacpan.org/module/XML::LibXML::Node#nonBlankChildNodes

#!/usr/bin/perl -- use strict; use warnings; use XML::LibXML 1.70; ## for load_html/load_xml/location use Data::Dump qw/ dd pp /; Main( @ARGV ); exit( 0 ); sub Main { my $loc = shift or die " Usage: $0 ko00010.xml $0 http://example.com/ko00010.xml\n\n"; my $dom = XML::LibXML->new( qw/ recover 2 / )->load_xml( location => $loc, ); orWhat( $dom -> documentElement ); } sub orWhat { my( $parent, $depth ) = @_; $depth ||= 0; my $dent = ' ' . ' ' x $depth; for my $child ( $parent->getAttributes ){ printf "%s%s[%s]\n", $dent, $child ->getName, $child->getValue +; } for my $kid ( $parent->nonBlankChildNodes ){ printf "%s%s[%s]\n", $dent, $kid->getName, pp( $kid->getValue +); orWhat( $kid, $depth + 1 ); ## recurse } return; } __END__ name[path:ko00010] org[ko] number[00010] title[Glycolysis / Gluconeogenesis] image[http...] link[http...] entry[undef] id[13] name[ko:K01623 ko:K01624 ko:K01622 ko:K16306] link[http...] graphics[undef] name[K01623...] fgcolor[#000000] bgcolor[#BFBFFF] type[rectangle] x[483] y[404] width[46] height[17]


Comment on Re^5: Parsing xml using libXML
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045104]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-08-01 17:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (36 votes), past polls