Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

XML::LibXML and namespaces

by Anonymous Monk
on Nov 09, 2012 at 09:29 UTC ( #1003089=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $parser = XML::LibXML->new->parse_file($file);
    my $xml = XML::LibXML::XPathContext->new($parser);
    $xml->registerNs($string,'http://www.garmin.com/xmlschemas/TrainingCen
    +terDatabase/v2');
    
  2. or download this
    for my $key ($xml->findnodes('//x:Lap')) {
     $string = norm_date($key->findvalue("\@StartTime"));
    }
    
  3. or download this
    for my $node ($xml->findnodes('//y:Trackpoint')) {
     $time = $node->findvalue("Time");
     push @X,$time;
    }
    
  4. or download this
    for my $node ($xml->findnodes("//y:Trackpoint")) {
     for my $ch ($node->childNodes) {
    ...
     }
     push @X,$time;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1003089]
Approved by marto
help
Chatterbox?
[choroba]: I usually do this with presentations
[Corion]: But now I think statically (re)generating the Pod tests is a saner approach, and likely I'll regenerate the tests either in Makefile.PL or from xt/ but have them live below t/
[choroba]: I keep the snippets in files of their own, and use a Makefile to syntax highlight them and insert them into slides, while also running them and inserting the output if required
[Corion]: choroba: Ooooh - I didn't think of that! I write my presentations as POD and if it "roughly" looks like Perl code, I should also syntax-check that...
[haukex]: Yes sorry I don't run them all the time, my POD tests are only run as author tests (and are excluded when I'm using Devel::Cover)
[Corion]: choroba: Hmm - no, I keep the snippets inline, but as my framework also has support for capturing output etc., maybe I should do the same...
[Corion]: haukex: Yes, that approach is sane, and it heals the fragility of Pod parsers in a nice way while still syntax-checking stuff
[choroba]: Unfortunately, none of it is online
[haukex]: I figured that POD tests make sense, but only as author tests
[choroba]: I mean, the slides are, but not the makefile with scripts to create them

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2017-02-27 12:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (385 votes). Check out past polls.