xml parser 101 - $current_element

W

werwer

Hey I'm just starting this ... so have mercy.

I'm spinning up some examples in "XML and Perl" Riehl & Sterin
(Did New Riders publishing go out of business?)

In their examples they parse files with a global value
called $current_element, assigned by the callback start_element().

Just a quick question. Seems that if a substructure uses
the same element name, you won't know where you are. If 'name' is
used in, say an employee section, and then again in his pet's
name, how will the callback know which name?

I would have guessed that $current_element was "appended" as the
parse drilled, but doesn't seem to work that way. start_element()
simply gives the present elements name.

Is it up to me to remember where I am?

(Sorry if this is too Perly. It's all I know. I post there too.
THanks)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,250
Members
46,848
Latest member
Graciela Mitchell

Latest Threads

Top