iterate through node attributes

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

iterate through node attributes

kevid
hi all,

please i have this xml document below. i want  to a assign it to a
variable  a hash of the xml document. the hash will be in the format:

"attribute_name"=> "attribute_value"

I would wand to use Xpath. Any clue from anyone is welcomed

<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok" version="1.0">
<event id="12995" name="The Samples" description=""
start_date="2005-04-16"
    end_date="" start_time="19:00:00" end_time=""
    personal="0" selfpromotion="0" metro_id="1" venue_id="155"
    user_id="8172" category_id="1" date_posted="2005-02-14"
    latitude="37.765" longitude="-122.396"
geocoding_precision="address"
    geocoding_ambiguous="0" venue_name="The Wiltern"
    venue_address="3790 Wilshire Blvd" venue_city="Los Angeles"
    venue_state_name="California" venue_state_code="ca"
    venue_state_id="5" venue_country_name="United States"
    venue_country_code="us" venue_country_id="1"
    venue_zip="90010"
    ticket_url="" ticket_price="" ticket_free="1" photo_url="" />
<event id="12996" name="The Samples" description=""
start_date="2005-04-16"
    end_date="" start_time="23:00:00" end_time=""
    personal="0" selfpromotion="0" metro_id="1" venue_id="155"
    user_id="8172" category_id="1" date_posted="2005-02-14"
    latitude="37.7665" longitude="-122.43"
geocoding_precision="address"
    geocoding_ambiguous="0" venue_name="The Wiltern"
    venue_address="3790 Wilshire Blvd" venue_city="Los Angeles"
    venue_state_name="California" venue_state_code="ca"
    venue_state_id="5" venue_country_name="United States"
    venue_country_code="us" venue_country_id="1"
    venue_zip="90010"
    ticket_url="" ticket_price="" ticket_free="1" photo_url="" />
</rsp>
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: iterate through node attributes

Martin Honnen-3
kevid wrote:

> please i have this xml document below. i want  to a assign it to a
> variable  a hash of the xml document. the hash will be in the format:
>
> "attribute_name"=> "attribute_value"
>
> I would wand to use Xpath. Any clue from anyone is welcomed

You can select all attribute nodes of all element nodes with the XPath
   descendant::*/@*




--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml