Hello Kind Monks:
After some more hacking and reading, found my errors
This code will do the trick:
my @el = $posNode->getElementsByTagName("itemName", 0); print scalar @el; print " " . $el[0]->getNodeName() . " " . nodeTypeText($el[0]- +>getNodeType()) ." \n" ;
bottom line getElementsByTagName works just fine.
I have been tasked with parsing a XML document that contains inventory info. The root level is <inventory> and then within inventory there are the inventory items, Ie <item1>, <item2>, <item3> ....... Within each inventory item there are many elements that describe that particular item. Ie <itemName>jeans501</itemName>, <itemId>j501ab</itemId>, <countryOrgin>mexico</countryOrgin>, <style>, etc...
Using XML::DOM I have written code that will rip through the XML and dump the elements one-by-one.
Here is my issue.
Given the node <item1> how do I ask for the node named "itemName" and ask for the node named "countryOrgin"? I wan t to ask for the info I need rather than ripping through the full item and then grapping the data. The way a database recordset would work.
I think that would be prettier code.
Thanks for considering my issue.
kd
In reply to XML::DOM get Element By Name by kevind0718
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |