📄 ch09_01.htm
字号:
<html><head><title>RSS, SOAP, and Other XML Applications (Perl and XML)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Erik T. Ray and Jason McIntosh" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly & Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="059600205XL" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Perl and XML" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img alt="Book Home" border="0" src="gifs/smbanner.gif" usemap="#banner-map" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Perl & XML" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch08_04.htm"><img alt="Previous" border="0" src="../gifs/txtpreva.gif" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch09_02.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr></table></div><h1 class="chapter">Chapter 9. RSS, SOAP, and Other XML Applications </h1><div class="htmltoc"><h4 class="tochead">Contents:</h4> <p> <a href="#perlxml-CHP-9-SECT-1">XML Modules</a><br /><a href="ch09_02.htm">XML::RSS </a><br /><a href="ch09_03.htm">XML Programming Tools </a><br /><a href="ch09_04.htm">SOAP::Lite </a><br /></p></div><p>In the next couple of chapters, we'll cover, at longlast, what happens when we pull together all the abstract tools andstrategies we've discussed and start having XMLdance for us. This is the land of the XML application, where parsersall have a bone to pick, picking up documents with a goal in mind. Nolonger satisfied with picking out the elements and attributes andcalling it a day, these higher-level tools look for meaning in allthat structure, according to directives that have been programmedinto it.</p><p>When we say XML application, we are specifically referring toXML-based document formats, not the computer programs (applicationsof another sort) that do stuff with them. You may run acrossstatements such as "GreenMonkeyML is an XMLapplication that provides semantic markup for greenmonkeys." Visiting the project'shome page at <em class="emphasis">http://www.greenmonkey-markup.com</em>, we mightencounter documentation describing how this specific format works,example documents, suggested uses for it, a DTD or schema used tovalidate GreenMonkeyML documents, and maybe an online validationtool. This content would all fit into the definition of an XMLapplication.</p><p>This chapter looks at XML applications that already have a strongpresence in the Perl world, by way of publicly available Perl modulesthat know how to handle them.</p><div class="sect1"><a name="perlxml-CHP-9-SECT-1" /></a><h2 class="sect1">9.1. XML Modules</h2><p>The term <em class="emphasis">XMLmodules</em><a name="INDEX-720" /></a>narrows us down from the Perl modules on CPAN that send mail, processimages, and play games, but it still leaves us with a very broadcross section. So far in this book, we have exhaustively covered Perlextensions that can perform general XML processing, but none thatperform more targeted functions based on general processing. In theend, they hand you a plate of XML chunklets, free of any inherentmeaning, and leave it to you to decide what happens next. In many ofthe examples we've provided so far in this book, wehave written programs that do exactly this: invoke an XML parser tochew up a document and then cook up something interesting out of theelements and attributes we get back.</p><p>However, the modules we're thinking about here giveyou more than the generic parse-and-process module family by buildingon one of the parsers and abstracting the processing in a specificdirection. They then provide an API that, while it might stillcontain hooks into the raw XML, concentrates on methods and routinesparticular to the XML application that they implement.</p><p>We can divide these XML application-mangling Perl modules into threetypes. We'll examine an example of each in thischapter, and in the next chapter, we'll try to makesome for ourselves.</p><dl><a name="INDEX-721" /></a><dt><i>XML application helpers </i></dt><dd><p>Helper modules are the humblest of the lot. In practice, they areoften little more than wrappers around raw XML processors, butsometimes that's all you need. If you find yourselfwriting several programs that need to read from and write to aspecific XML-based document format, a helper module can providecommon methods, freeing the programmer from worrying about theapplication's exact document format or itswell-formedness in generated output. The module will take care of allthat.</p></dd><dt><i>Programming helpers that use XML </i></dt><dd><p>This small but growing category describes Perl extensions that useXML to do cool stuff in your program, even if yourprogram's input or output has little to do with XML.Currently, the most prominent examples involve the terrifying,DBI-like powers of <tt class="literal">XML::SAX</tt>, the whole PerlSAX2family, and individual tools like the<tt class="literal">XML::Generator::DBI</tt> module, which crossbreedsexisting Perl modules for database manipulation and SAX processing.</p></dd><dt><i>Full-on applications that use XML </i></dt><dd><p>Finally, we have software that uses XML, but has so many layers ofabstraction between its intended purpose and the underlying XML thatcalling it an XML application is like calling Microsoft Word a Capplication. For example, working with <tt class="literal">SOAP::Lite</tt>involves documents that are barely human-readable and exist only inmemory until they're shot over the Internet viaHTTP; the role of XML in SOAP is completely transparent.</p></dd></dl></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch08_04.htm"><img alt="Previous" border="0" src="../gifs/txtpreva.gif" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img alt="Home" border="0" src="../gifs/txthome.gif" /></a></td><td align="right" valign="top" width="228"><a href="ch09_02.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr><tr><td align="left" valign="top" width="228">8.4. Optimized Tree Processing</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img alt="Book Index" border="0" src="../gifs/index.gif" /></a></td><td align="right" valign="top" width="228">9.2. XML::RSS </td></tr></table></div><hr width="684" align="left" /><img alt="Library Navigation Links" border="0" src="../gifs/navbar.gif" usemap="#library-map" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2002</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -