Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^3: XML::Twig help

by mirod (Canon)
on Jul 03, 2012 at 13:43 UTC ( #979704=note: print w/replies, xml ) Need Help??

in reply to Re^2: XML::Twig help
in thread XML::Twig help

There are several ways to get the data. first_child only goes down 1 step in the tree. To get the text, you would need $drug->first_child('groups')->field( 'group'), or $drug->next_elt( 'groups')->text or $drug->findvalue( 'groups/group'). INTEREST1 is an attribute, so you would get it with $drug->att( 'type').

There is probably a problem though either with your simplified data or with the code. You have te tags in your example as data1 and data2. If this is really the case, then you won't access them with $root->children('data'), since the tags are NOT data. So either the tags are data, or you have to get them using $root->children.

Replies are listed 'Best First'.
Re^4: XML::Twig help
by yesitsjess (Initiate) on Jul 05, 2012 at 10:36 UTC

    Thank you, that is very helpful. And yes the tags data1 data2 should just be data, that was my mistake :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://979704]
[choroba]: Isn't Using PerlPod Creatively rather a meditation?
[choroba]: I don't see a question
[1nickt]: ugh, I stuck my head in the bass bin for 30 seconds on a dare at Ted Nugent at Hammersmith Odeon. Yes, I am 40% deaf now.
[johngg]: My daughter is incredibly jealous of my wife who got to see The Clash at Brixton many years ago. They went to see The Vaccines there recently.
[1nickt]: But the bands are even louder! I saw Spearhead (Michael Franti) at an outdoor show and had to walk a mile away to not feel pain in my chest! Babies were crying ... I asked the sound engineer why it was necessary to have the bass so loud and he laughed...
[Discipulus]: but the best i attended live was Mano Negra Patchanka at Forte Prenestino .. in 1990
[Corion]: Hmmm - Mano Negra or at least Manu Chao seem to put on a good live show. At least the one live CD I have from Manu Chao sounds good ;)
Discipulus feels the same jealousity of the johngg's daughter
[1nickt]: choroba I agree

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2017-03-24 12:15 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (301 votes). Check out past polls.