# NWS-NOAA: accessing attributes with SOAP4R

**URL:** <https://www.ruby-forum.com/t/nws-noaa-accessing-attributes-with-soap4r/69588>\
**Category:** Ruby\
**Created:** [February 17, 2006, 9:13am UTC](https://www.ruby-forum.com/t/nws-noaa-accessing-attributes-with-soap4r/69588 "2006-02-17T09:13:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Verbeure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/848f3c/32.png) [@Tom\_Verbeure](https://www.ruby-forum.com/u/Tom_Verbeure)\
**Post date:** [February 17, 2006, 9:13am UTC](https://www.ruby-forum.com/t/nws-noaa-accessing-attributes-with-soap4r/69588/1 "2006-02-17T09:13:42Z")

</div>

Hi Ruby Guru’s,

I’ve successfully retrieved data from the NWS weather server with the  
example that was give at the following link:  
[http://groups.google.com/group/comp.lang.ruby/msg/5fb9a1506ea46b2e](http://groups.google.com/group/comp.lang.ruby/msg/5fb9a1506ea46b2e)

So far so good.

However, I’m only able to get text data, that is the data that’s not  
part of an XML tag. I did not find a way to access XML attributes.

E.g.: I have no problem to get the ‘point1’ information, indicated by  
, but I can find a way to get ’

```
  <location>
     <location-key>point1</location-key>
     <point latitude="38.99" longitude="-77.99" />
  </location>
  <time-layout time-coordinate="local" summarization="none">
      <layout-key>k-p24h-n7-1</layout-key>

```

The closest I’ve gotten to see that the data is actually there is by  
doing:

p data[‘location’][‘point’].\_\_xmlattr

This prints something that lists ‘latitude’ and ‘longitude’. But how do  
I access the value itself?

p data[‘location’][‘point’].\_\_xmlattr[‘latitude’] or  
p data[‘location’][‘point’].latitude

doesn’t work.

Any suggestions are greatly appreciated!

Tom

---

<div class="post-metadata">

**Author:** ![Tom\_Verbeure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/848f3c/32.png) [@Tom\_Verbeure](https://www.ruby-forum.com/u/Tom_Verbeure)\
**Post date:** [February 17, 2006, 9:40am UTC](https://www.ruby-forum.com/t/nws-noaa-accessing-attributes-with-soap4r/69588/2 "2006-02-17T09:40:50Z")

</div>

Hey,

Well, I’m not an expert (yet:) in Ruby, but I stumbled across the  
“extraattr”-attribute of the SOAPElement in the SOAP4R-library.

See [http://www.ruby-doc.org/stdlib/libdoc/soap/rdoc/index.html](http://www.ruby-doc.org/stdlib/libdoc/soap/rdoc/index.html) and  
[Peak Obsession](http://wiki.rubyonrails.com/rails/pages/PayPalWebServices) for more  
details.

Maybe that’ll help you?

Holgi

---

<div class="post-metadata">

**Author:** ![Tom\_Verbeure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/848f3c/32.png) [@Tom\_Verbeure](https://www.ruby-forum.com/u/Tom_Verbeure)\
**Post date:** [February 18, 2006, 12:04am UTC](https://www.ruby-forum.com/t/nws-noaa-accessing-attributes-with-soap4r/69588/3 "2006-02-18T00:04:36Z")

</div>

Hi Holgi,

Thanks for the pointers. Unfortunately, it seems that I’m dealing with  
a SOAP::Mapping:Object instead of a SOAPElement. I’ll let you know if I  
make any progress.

Tom
