06.01.2013 Views

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

344 <strong>Learning</strong> <strong>Processing</strong><br />

18.7<br />

return true;<br />

} else {<br />

return false;<br />

}<br />

}<br />

}<br />

Beginner XML<br />

Th e examples in Section 18.4 demonstrated the process of manually searching through text for individual<br />

pieces of data. Admittedly, manually parsing the raw XML data from http://xml.weather.yahoo.com/<br />

forecastrss?p � 10003 was not the most effi cient strategy. Yes, if you need information from an oddly<br />

formed HTML page, these manual techniques are required. However, because XML is designed <strong>to</strong><br />

facilitate the sharing of data across diff erent systems, it can be parsed without manual searching, using an<br />

XML parsing library.<br />

XML organizes information in a tree structure. Let’s imagine a list of students. Each student has an id<br />

number, name, address, e-mail, and telephone number. Each student’s address has a city, state, and zip<br />

code. An XML tree for this dataset might look like Figure 18.12 .<br />

Student Student Student Student<br />

fi g. 18.12<br />

Students<br />

Th e XML source itself (with two students listed) is:<br />

id name phone e-mail address<br />

street city state zip<br />

� ?xml version = " 1.0 " encoding = " UTF-8 " ? �<br />

� students �<br />

� student �<br />

� id � 001 � /id �<br />

� name � Daniel Shiffman � /name �<br />

� phone � 555-555-5555 � /phone �<br />

� email � daniel@shiffman.net � /email �<br />

� address �<br />

� street � 123 <strong>Processing</strong> Way � /street �<br />

� city � Loops � /city �<br />

� state � New York � /state �<br />

� zip � 01234 � /zip �<br />

� /address �<br />

� /student �

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!