Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^4: XML Parsing

by vmallya (Initiate)
on Feb 08, 2013 at 14:14 UTC ( #1017831=note: print w/replies, xml ) Need Help??

in reply to Re^3: XML Parsing
in thread XML Parsing

Harish, I see that when using content() to return contents of the node and that $xml_smart_obj was always returning one element, whereas the xml has multiple entries for the tag <parameter>. 1. How to list down all the pointers/contents for the tag <parameter> 2. Can I see the array size using $#xml_obj ? Thanks

Replies are listed 'Best First'.
Re^5: XML Parsing
by tmharish (Friar) on Feb 08, 2013 at 14:25 UTC

    ->pointer will actually give you the tree starting from where you have traversed to in the xml_smart object. It will be a hash which you can use like an ordinary hash.

    You can traverse the object using the method described above and it will move the pointer.

    ___________node1 | root ---|-----------node2 |___________node3 ^ |________________Pointer could be here.

    Now when you ask for ->content() it will give you the content at node3 and if you ask for ->pointer it will give you the sub-tree starting from node3 in a hash.

    Hope that helps - Let me know if you need further clarification.

      Harish, Thanks for the clarification. One more doubt, say for node1, node2 i have defined an attribute, can i put a check something like if exists {node}(instance) ? Also how to access the value of attribute if it exists for each node. Regards Vishranth

        I might be able to clear up things if you can list out all the things you want to extract from the xml that you have provided - or you might even want to provide a more extensive xml.

        So something like:

        I want to access the "value" based on the attribute "category" and also in case I have multiple parameters with different "instances".

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017831]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2018-05-23 11:49 GMT
Find Nodes?
    Voting Booth?