23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 5.3: Illustrat<strong>in</strong>g HTML tags. (a) An HTML<br />

document; (b) its render<strong>in</strong>g.<br />

Fortunately, more or less the same algorithm as <strong>in</strong> Code Fragment 5.10 can be<br />

used to match the tags <strong>in</strong> an HTML document. In Code Fragments 5.11 <strong>and</strong> 5.12,<br />

we give a <strong>Java</strong> program for match<strong>in</strong>g tags <strong>in</strong> an HTML document read from<br />

st<strong>and</strong>ard <strong>in</strong>put. For simplicity, we assume that all tags are the simple open<strong>in</strong>g or<br />

clos<strong>in</strong>g tags def<strong>in</strong>ed above <strong>and</strong> that no tags are formed <strong>in</strong>correctly.<br />

Code Fragment 5.11: A complete <strong>Java</strong> program for<br />

test<strong>in</strong>g if an HTML document has fully match<strong>in</strong>g tags.<br />

(Cont<strong>in</strong>ues <strong>in</strong> Code Fragment 5.12.)<br />

282

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

Saved successfully!

Ooh no, something went wrong!