Perl XML::LibXML by Example Documentation
Perl XML::LibXML by Example Documentation
Release
Grant McLean
January 29, 2020
CONTENTS
1 A Basic Example
3
1.1 Other XML sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 A more complex example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3 Accessing attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.4 Attributes via tied hash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5 Parsing Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2 XPath Expressions
13
2.1 XPath Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3 The Document Object Model
17
3.1 The `Document' object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2 `Element' objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3 `Text' objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.4 `Attr' objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.5 `NodeList' objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.6 Modifying the DOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.7 Creating a new Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4 Working with XML Namespaces
29
5 Working With Large Documents
33
5.1 The Reader Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.2 Bring Back the DOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.3 Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.4 Working With Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6 Working with HTML
41
6.1 Querying HTML with XPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.2 Matching class names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.3 Using CSS-style selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
7 Installing XML::LibXML
47
7.1 Installing on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.2 Installing on Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.3 Installing on Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
8 Alternate Formats
49
9 Corrections and Updates
51
10 Contributors
53
i
ii
Perl XML::LibXML by Example Documentation, Release
The XML::LibXML Perl module is a wrapper around the libxml2 parser library which is written in C. This tutorial uses example code to introduce the features of XML::LibXML and the ways in which you can use the module. The example scripts and XML documents are available as a ZIP file download. Get started with a basic example or jump directly to a specific topic using the Table of Contents.
CONTENTS
1
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- comparing and contrasting xml features of db2 and cobol
- libxml tutorial mit
- reading xml with fme safe software
- 1 dom parser example sax parser
- perl xml libxml by example documentation
- reading and writing xml files from sas
- xml tutorial the xml c parser and toolkit of gnome
- parsing xml stat 133
- homework 1 tutorial abscon webgrader and the c xml
- getting data from the web with r chalmers