• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 22. XML and XSLT > Accessing Attribute Values in XML Elements

Accessing Attribute Values in XML Elements

Like HTML elements, XML elements can have attributes. To show how to read attribute values from an XML document, I’ll create a new example to read the value of the ATTENDENCE attribute of the third person in the XML document 22-01.xml:

<?xml version="1.0"?> 
<EVENTS> 
    <EVENT TYPE="informal"> 
       <EVENT_TITLE>15th Award Ceremony</EVENT_TITLE> 
       <EVENT_NUMBER>1207</EVENT_NUMBER> 
       <SUBJECT>Gala Event</SUBJECT> 
       <DATE>7/4/2003</DATE> 
       <PEOPLE> 
           <PERSON ATTENDENCE=”present”> 
               <FIRST_NAME>Sam</FIRST_NAME> 
               <LAST_NAME>Edwards</LAST_NAME> 
           </PERSON> 
           <PERSON ATTENDENCE=”absent”> 
               <FIRST_NAME>Sally</FIRST_NAME> 
               <LAST_NAME>Jackson</LAST_NAME> 
           </PERSON> 
           <PERSON ATTENDENCE=”present”> 
               <FIRST_NAME>Cary</FIRST_NAME> 
               <LAST_NAME>Grant</LAST_NAME> 
           </PERSON> 
       . 
       . 
       . 

					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint