ptg7068951
Workshop 311
- What method reads all the elements that are enclosed within a parent
element?
A. get()
B. getChildElements()
C. getFirstChildElement() - What method of the Elementsclass can be used to determine the num-
ber of elements that it contains?
A. count()
B. length()
C. size()
Answers
- C.Well-formed data has properly structured start and end tags,a single
root element containing all child elements,and an ?XMLdeclaration at
the top. Valid data follows the rules of a particular XML dialect. “Dy-no-
mite!” is the catchphrase of the comedian Jimmie “J.J.” Walker. - B.ThegetChildElements()method returns an Elementsobject holding
all the elements. - C.Just like vectors,Elementsuses a size()method that provides a
count of the items it holds.
Activities
Toextend your knowledge of XML,parse the following activities:
. Revise the WeatherStationapplication to display an additional element
from the Weather Underground forecast data.
. Write a program that displays the data contained in shortChanges.xml,
an XML document of weblog information available at
http://www.weblogs.com/shortChanges.xml.
To s e e J av a p r o g r a m s t h a t i m p l e m e n t t h e s e a c t i v i t i e s ,visit the book’s website
at http://www.java24hours.com.