Go Down

Topic: XML Feeds (Read 2073 times) previous topic - next topic

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1231812230.
I need to create two feeds. One will display the current date and time and the other will display how many new emails I have in Gmail (my email provider). I will then combine the two feeds to create one feed that I will retrieve using the code provided earlier. Does anybody know any services that will allow me to do this?

Thanks, Carnyworld...

PS: Sorry if this is the wrong section, its the best section that I could find.
C program run. C program crash. C programmer quit.

#1
Dec 29, 2010, 06:59 pm Last Edit: Dec 29, 2010, 06:59 pm by Carnyworld Reason: 1
What I am asking is how I can see how I can see how many emails I have, the current time, and what the current temperature is... All via rss feed.
C program run. C program crash. C programmer quit.

robtillaart

#2
Dec 29, 2010, 07:13 pm Last Edit: Dec 29, 2010, 07:13 pm by robtillaart Reason: 1
you crossposted (?) and I answered in the other thread - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293601117

If you search the forum with weather and web you should ffind relevant links for temp.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Yeah, ignore the other post. How would I display the Current Time though?
C program run. C program crash. C programmer quit.

robtillaart

Connect a DS1307 RTC (RealTime Clock) to your Arduino. Lady ada sells a nice shield with RTC and has a tutorial on their site how to use the RTC library. See - http://www.ladyada.net/make/logshield/

Once you set the time of the DS1307 it will be quite accurate for years. You can set the RTC by means of the NTP protocol, see - http://www.arduino.cc/playground/Main/DS1307OfTheLogshieldByMeansOfNTP

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

I now have a feed at http://www.google.com/reader/atom/user%2F15916171905404598697%2Flabel%2FArduino

I need help with this part of code:
Code: [Select]
  // Find specific tags and print data
     if (matchTag("<temp_f>")) {
           Serial.print("Temp: ");
        Serial.print(dataStr);
     }
     if (matchTag("<relative_humidity>")) {
           Serial.print(", Humidity: ");
        Serial.print(dataStr);
     }
     if (matchTag("<pressure_in>")) {
           Serial.print(", Pressure: ");
        Serial.print(dataStr);
        Serial.println("");
     }

How can I extract the text of each emails subject line as they all have the same tags which in this case is <title type="html"></title>.

Currently also I have the feed displaying more than just temperature. How can I extract only the temperature and nothing else?
C program run. C program crash. C programmer quit.

Here is the Feed:

Code: [Select]
This XML file does not appear to have any style information associated with it. The document tree is shown below.
     
[ch8722]
<feed idx:index="no" gr:dir="ltr">
<!--
Content-type: Preventing XSRF in IE.

-->
<generator uri="http://www.google.com/reader">Google Reader</generator>
[ch8722]
<id>
tag:google.com,2005:reader/user/15916171905404598697/label/Arduino
</id>
<title>"Arduino" via Christopher in Google Reader</title>
<link rel="self" href="http://www.google.com/reader/atom/user%2F15916171905404598697%2Flabel%2FArduino"/>
[ch8722]
<author>
<name>Christopher</name>
</author>
<updated>2010-12-29T23:02:09Z</updated>
[ch8722]
<entry gr:crawl-timestamp-msec="1293663729775">
<id gr:original-id="tag:gmail.google.com,2004:1356504650833327926">tag:google.com,2005:reader/item/ec593d1f5b807205</id>
<category term="user/15916171905404598697/label/Arduino" scheme="http://www.google.com/reader/" label="Arduino"/>
<category term="user/15916171905404598697/bundle/Arduino" scheme="http://www.google.com/reader/" label="Arduino"/>
<category term="user/15916171905404598697/bundle" scheme="http://www.google.com/reader/"/>
<category term="user/15916171905404598697/state/com.google/reading-list" scheme="http://www.google.com/reader/" label="reading-list"/>
<category term="user/15916171905404598697/state/com.google/fresh" scheme="http://www.google.com/reader/" label="fresh"/>
<title type="html">shadow</title>
<published>2010-12-29T23:00:45Z</published>
<updated>2010-12-29T23:00:45Z</updated>
<link rel="alternate" href="http://mail.google.com/mail?account_id=christopherjelledge@gmail.com&message_id=12d345caf915f736&view=conv&extsrc=atom" type="text/html"/>
[ch8722]
<summary xml:base="http://mail.google.com/mail" type="html">
This email was sent via Anonymous email service for free. YOU CAN REMOVE THIS TEXT MESSAGE BY ...
</summary>
[ch8722]
<author>
<name>Chkhdkj</name>
</author>
[ch8722]
<source gr:stream-id="feed/http://freemyfeed.com/feed/aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC9mZWVkL2F0b206OkNocmlzdG9waGVyamVsbGVkZ2U6OkY0VVIrWGI1TzdCemU4bmpNNEpjT3pvNk1RPT0=">
[ch8722]
<id>
tag:google.com,2005:reader/feed/http://freemyfeed.com/feed/aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC9mZWVkL2F0b206OkNocmlzdG9waGVyamVsbGVkZ2U6OkY0VVIrWGI1TzdCemU4bmpNNEpjT3pvNk1RPT0=
</id>
<title type="html">Gmail - Inbox for christopherjelledge@gmail.com</title>
<link rel="alternate" href="http://mail.google.com/mail" type="text/html"/>
</source>
</entry>
[ch8722]
<entry gr:crawl-timestamp-msec="1293663729775">
<id gr:original-id="tag:gmail.google.com,2004:1356502460486981398">tag:google.com,2005:reader/item/2a2148e7bd9ba34d</id>
<category term="user/15916171905404598697/label/Arduino" scheme="http://www.google.com/reader/" label="Arduino"/>
<category term="user/15916171905404598697/bundle/Arduino" scheme="http://www.google.com/reader/" label="Arduino"/>
<category term="user/15916171905404598697/bundle" scheme="http://www.google.com/reader/"/>
<category term="user/15916171905404598697/state/com.google/reading-list" scheme="http://www.google.com/reader/" label="reading-list"/>
<category term="user/15916171905404598697/state/com.google/fresh" scheme="http://www.google.com/reader/" label="fresh"/>
<title type="html">Test</title>
<published>2010-12-29T22:25:56Z</published>
<updated>2010-12-29T22:25:56Z</updated>
<link rel="alternate" href="http://mail.google.com/mail?account_id=christopherjelledge@gmail.com&message_id=12d343ccfe451716&view=conv&extsrc=atom" type="text/html"/>
<summary xml:base="http://mail.google.com/mail" type="html">Test</summary>
[ch8722]
<author>
<name>me</name>
</author>
[ch8722]
<source gr:stream-id="feed/http://freemyfeed.com/feed/aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC9mZWVkL2F0b206OkNocmlzdG9waGVyamVsbGVkZ2U6OkY0VVIrWGI1TzdCemU4bmpNNEpjT3pvNk1RPT0=">
[ch8722]
<id>
tag:google.com,2005:reader/feed/http://freemyfeed.com/feed/aHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vbWFpbC9mZWVkL2F0b206OkNocmlzdG9waGVyamVsbGVkZ2U6OkY0VVIrWGI1TzdCemU4bmpNNEpjT3pvNk1RPT0=
</id>
<title type="html">Gmail - Inbox for christopherjelledge@gmail.com</title>
<link rel="alternate" href="http://mail.google.com/mail" type="text/html"/>
</source>
</entry>
[ch8722]
<entry gr:is-read-state-locked="true" gr:crawl-timestamp-msec="1293658655144">
<id gr:original-id="CurrentTxt-Wed, 29 Dec 2010 21:00:00 GMT">tag:google.com,2005:reader/item/c8a200bc564d48a3</id>
<category term="user/15916171905404598697/state/com.google/read" scheme="http://www.google.com/reader/" label="read"/>
<category term="user/15916171905404598697/label/Arduino" scheme="http://www.google.com/reader/" label="Arduino"/>
<category term="user/15916171905404598697/bundle/Arduino" scheme="http://www.google.com/reader/" label="Arduino"/>
<category term="user/15916171905404598697/bundle" scheme="http://www.google.com/reader/"/>
<category term="user/15916171905404598697/state/com.google/reading-list" scheme="http://www.google.com/reader/" label="reading-list"/>
[ch8722]
<title type="html">
Current Conditions from Notre Dame HS, Sherman Oaks, CA
</title>
<published>2010-12-29T21:00:00Z</published>
<updated>2010-12-29T21:00:00Z</updated>
<link rel="alternate" href="http://web.live.weatherbug.com/Common/home.aspx?zcode=z4641&zip=91423&units=0&rnd=Obs122920101600" type="text/html"/>
[ch8722]
<summary xml:base="http://web.live.weatherbug.com/Common/Home.aspx?zcode=z4641&zip=91423" type="html">
<b>Temperature:</b> 52.9 °F          
                       <br>
                       <br>
                             <b>Humidity:</b> 99 %    
                             <b>Wind Speed:</b> 4 mph ESE    
                             <b>Pressure:</b> 29.63 &quot;    
                       <br>
                       <br>      
                             <b>Dew Point:</b> 53 °F    
                             <b>Gusts:</b> 15 mph E    
                             <b>Rain Today:</b> 0.42 &quot;    
                       <br>
</summary>
[ch8722]
<author gr:unknown-author="true">
<name>(author unknown)</name>
</author>
[ch8722]
<source gr:stream-id="feed/http://feeds.weatherbug.com/rss.aspx?zipcode=91423&feed=currtxt&zcode=z4641">
[ch8722]
<id>
tag:google.com,2005:reader/feed/http://feeds.weatherbug.com/rss.aspx?zipcode=91423&feed=currtxt&zcode=z4641
</id>
<title type="html">WeatherBug Current Conditions for 91423</title>
<link rel="alternate" href="http://web.live.weatherbug.com/Common/Home.aspx?zcode=z4641&zip=91423" type="text/html"/>
</source>
</entry>
[ch8722]
<entry gr:is-read-state-locked="true" gr:crawl-timestamp-msec="1293649440301">
<id gr:original-id="CurrentTxt-Wed, 29 Dec 2010 19:00:00 GMT">tag:google.com,2005:reader/item/595e0762c068ce17</id>
<category term="user/15916171905404598697/state/com.google/read" scheme="http://www.google.com/reader/" label="read"/>
<category term="user/15916171905404598697/label/Arduino" scheme="http://www.google.com/reader/" label="Arduino"/>
<category term="user/15916171905404598697/bundle/Arduino" scheme="http://www.google.com/reader/" label="Arduino"/>
<category term="user/15916171905404598697/bundle" scheme="http://www.google.com/reader/"/>
<category term="user/15916171905404598697/state/com.google/reading-list" scheme="http://www.google.com/reader/" label="reading-list"/>
[ch8722]
<title type="html">
Current Conditions from Notre Dame HS, Sherman Oaks, CA
</title>
<published>2010-12-29T19:00:00Z</published>
<updated>2010-12-29T19:00:00Z</updated>
<link rel="alternate" href="http://web.live.weatherbug.com/Common/home.aspx?zcode=z4641&zip=91423&units=0&rnd=Obs122920101400" type="text/html"/>
[ch8722]
<summary xml:base="http://web.live.weatherbug.com/Common/Home.aspx?zcode=z4641&zip=91423" type="html">
<b>Temperature:</b> 51.6 °F          
                       <br>
                       <br>
                             <b>Humidity:</b> 99 %    
                             <b>Wind Speed:</b> 4 mph ESE    
                             <b>Pressure:</b> 29.7 &quot;    
                       <br>
                       <br>      
                             <b>Dew Point:</b> 51 °F    
                             <b>Gusts:</b> 15 mph E    
                             <b>Rain Today:</b> 0.42 &quot;    
                       <br>
</summary>
[ch8722]
<author gr:unknown-author="true">
<name>(author unknown)</name>
</author>
[ch8722]
<source gr:stream-id="feed/http://feeds.weatherbug.com/rss.aspx?zipcode=91423&feed=currtxt&zcode=z4641">
[ch8722]
<id>
tag:google.com,2005:reader/feed/http://feeds.weatherbug.com/rss.aspx?zipcode=91423&feed=currtxt&zcode=z4641
</id>
<title type="html">WeatherBug Current Conditions for 91423</title>
<link rel="alternate" href="http://web.live.weatherbug.com/Common/Home.aspx?zcode=z4641&zip=91423" type="text/html"/>
</source>
</entry>
</feed>
C program run. C program crash. C programmer quit.

robtillaart

#7
Dec 30, 2010, 09:17 am Last Edit: Dec 30, 2010, 09:24 am by robtillaart Reason: 1
Quote
How can I extract the text of each emails subject line as they all have the same tags which in this case is <title type="html"></title>.


Think you just need to add the following code for your email-titles and as the code parses all XML passing by they will all be detected.. give it a try.

Code: [Select]
     
if (matchTag("<title type=\"html\">"))    // NOTE the \ 's
{
 Serial.print(", Mail:  ");
 Serial.print(dataStr);
 Serial.println();                  // omit ""
}


so add all the 'stuff found' in the tag or do a half Tag test

Code: [Select]
     
if (matchTag("<title "))    // simpler match not as robust but will prob work.
{
 Serial.print(", Mail:  ");
 Serial.print(dataStr);
 Serial.println();                  // omit ""
}


As matchTag() is just a wrapper around stringcmp(),  you can speed up things a tiny bit by using strcmp directly.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

robtillaart

#8
Dec 30, 2010, 09:30 am Last Edit: Dec 30, 2010, 09:31 am by robtillaart Reason: 1
Quote
Currently also I have the feed displaying more than just temperature. How can I extract only the temperature and nothing else?


What does it show - note that the forummembers cannot see your display :)

Please share your whole code as that makes it much easier to help.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy