⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch01_01.htm

📁 Perl & XML. by Erik T. Ray and Jason McIntosh ISBN 0-596-00205-X First Edition, published April
💻 HTM
字号:
<html><head><title>Perl and XML (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 &amp; 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 &amp; 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="ch00_06.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="ch01_02.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr></table></div><h1 class="chapter">Chapter 1. Perl and XML</h1><div class="htmltoc"><h4 class="tochead">Contents:</h4>  <p> <a href="#perlxml-CHP-1-SECT-1">Why Use Perl with XML? </a><br /><a href="ch01_02.htm">XML Is Simple with XML::Simple</a><br /><a href="ch01_03.htm">XML Processors</a><br /><a href="ch01_04.htm">A Myriad of Modules</a><br /><a href="ch01_05.htm">Keep in Mind...</a><br /><a href="ch01_06.htm">XML Gotchas</a><br /></p></div><p>Perl is a mature but eccentric programming language that istailor-made for text manipulation. XML is a fiery young upstart of atext-based markup language used for web content, document processing,web services, or any situation in which you need to structureinformation flexibly. This book is the story of the first few yearsof their sometimes rocky (but ultimately happy) romance.</p><div class="sect1"><a name="perlxml-CHP-1-SECT-1" /></a><h2 class="sect1">1.1. Why Use Perl with XML? </h2><p>First<a name="INDEX-5" /></a> and<a name="INDEX-6" /></a> <a name="INDEX-7" /></a> foremost, Perl is idealfor crunching text. It has filehandles,"here" docs, string manipulation,and regular expressions built into its syntax. Anyone who has everwritten code to manipulate strings in a low-level language like<a name="INDEX-8" /></a>C andthen tried to do the same thing in Perl has no trouble telling youwhich environment is easier for text processing. XML is text at itscore, so Perl is uniquely well suited to work with it.</p><p>Furthermore, starting with Version 5.6, Perl has been gettingfriendly with <a name="INDEX-9" /></a>Unicode-flavored character encodings,especially <a name="INDEX-10" /></a>UTF-8, which is important for XMLprocessing. You'll read more about characterencoding in <a href="ch03_01.htm">Chapter 3, "XML Basics: Reading and Writing"</a>.</p><p>Second, the <a name="INDEX-11" /></a>Comprehensive Perl Archive Network(CPAN) is a multimirrored heap of<a name="INDEX-12" /></a>modules free for the taking. You could saythat it takes a village to make a program; anyone who undertakes aprogramming project in Perl should check the public warehouse ofpackaged solutions and building blocks to save time and effort. Whywrite your own parser when CPAN has plenty of parsers to download,all tested and chock full of configurability? CPAN is wild andwoolly, with contributions from many people and not much supervision.The good news is that when a new technology emerges, a modulesupporting it pops up on CPAN in short order. This featurecomplements XML nicely, since it's always changingand adding new accessory technologies.</p><p>Early on, modules sprouted up around XML like mushrooms after a rain.Each module brought with it a unique interface and style that wasinnovative and Perlish, but not interchangeable. Recently, there hasbeen a trend toward creating a universal interface so modules can beinterchangeable. If you don't like this SAX parser,you can plug in another one with no extra work. Thus, the CPANcommunity does work together and strive for internal coherence.</p><p>Third, Perl's flexible, object-oriented programmingcapabilities are very useful for dealing with XML. An XML document isa hierarchical structure made of a single basic atomic unit, the XMLelement, that can hold other elements as its children. Thus, theelements that make up a document can be represented by one class ofobjects that all have the same, simple interface. Furthermore, XMLmarkup encapsulates content the way objects encapsulate code anddata, so the two complement each other nicely.You'll also see that objects are useful formodularizing XML processors. These objects include parser objects,parser factories that serve up parser objects, and parsers thatreturn objects. It all adds up to clean, portable code.</p><p>Fourth, the link between Perl and the <a name="INDEX-13" /></a><a name="INDEX-14" /></a><a name="INDEX-15" /></a>Web is important. <a name="INDEX-16" /></a>Java and<a name="INDEX-17" /></a>JavaScript get all the glamour, but anyweb monkey knows that Perl lurks at the back end of most<a name="INDEX-18" /></a>servers. Manyweb-munging libraries in Perl are easily adapted to XML. Thedevelopers who have worked in Perl for years building web sites arenow turning their nimble fingers to the XML realm.</p><p>Ultimately, you'll choose the programming languagethat best suits your needs. Perl is ideal for working with XML, butyou shouldn't just take our word for it. Give it atry.</p></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch00_06.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="ch01_02.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr><tr><td align="left" valign="top" width="228">0.6. Acknowledgments</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">1.2. XML Is Simple with XML::Simple</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 &copy; 2002</a> O'Reilly &amp; 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 + -