background preloader

XPath

Facebook Twitter

DOM XML: An Alternative to Expat. Get to know the QueryPath PHP library. Introduction You could make the case that, over the past 15 years, the three technologies that have contributed most to the Web's explosive growth are HTML, HTTP, and XML. You might expand upon this triumvirate, pointing perhaps to CSS, JavaScript, and similar technologies. But the "big three" remain unchallenged at the top of the list.

PHP has also made a splash in the Web-development world. PHP powers Web sites from small home pages to the likes of Yahoo! , largely because of its ease of development and Web-centered model. Simplicity, to make it easy to work with HTML, XML, and HTTPRobustness, to provide a rich site of tools for working with these technologies This article explores building QueryPath objects, traversing XML and HTML, manipulating XML and HTML, and using QueryPath to access a Web service (Twitter is the example service). The next section has a brief introduction to the library and its design. Back to top QueryPath For simplicity, QueryPath uses a compact syntax.

Requirements. Using the HTML Table Element as a Recordset. Using the HTML Table Element as a Recordset(Page 1 of 5 ) Introduction This article is written for those who have basic knowledge in database programming, HTML, CSS and JavaScript. Recordset is a name given to the result of a database query. There are other names for it, such as resultSet. This result is in the memory of the client’s computer.

For a language like C++, there are APIs, which link the database program (code to manipulate the data) to the database engine. These APIs have (produce) the recordset, which is accessed by the programming language (C++). If we are to use JavaScript as the programming language, what recordset shall we use? But what about the HTML TABLE element? Seen as a recordset, the field data of a row of the TABLE element is the content of the TD element. The HTML TABLE element as a recordset has the following advantages over classical recordsets: It does not have to be only two-dimensional; it can be three- or even four-dimensional.

Save time and code with XPath 2.0 and XSLT 2.0. One of the major new concepts in XPath 2.0 and XSLT 2.0 is that everything is a sequence. In XPath 1.0 and XSLT 1.0, you typically worked with trees of nodes. The parsed XML document was a tree that contained the document node and its descendants. Using that tree of nodes, you could find the node for the root element, along with all of the root element's descendants, attributes, and siblings. (Any comments or processing instructions outside the root element of the XML file are considered siblings of the root element.) When you work with an XML document in XPath 2.0 and XSLT 2.0, you use the sequence in the same way as the tree structure in XPath 1.0 and XSLT 1.0. The sequence contains a single item (the document node), and you use it the same way you always have.

However, you can create sequences of atomic values. Listing 1. This code defines the variable $seeds. Sequences follow a couple of rules. Listing 2. Listing 3. Listing 4. Understanding the sample application Listing 5. <? <! Introduction to XPath. Introduction to XPath(Page 1 of 4 ) XPath, XML Path Language, is an expression language for addressing portions of an XML document or navigating within an XML document. We can also get values of elements and attributes using XPath. XPath is really helpful for parsing XML- based configuration or properties files. XPath is a major element in the XSLT standard. XPath uses path expressions to select nodes or node-sets in an XML document. These path expressions look very much like URL and traditional file system paths. XPath also supports several functions for string manipulation, comparison and others. First we will learn about these path expressions. <bookstore> <book> <title id='1'>XPath Tutorial</title> <author>Mamun Zaman</author> <year>2007</year> <price>00.99</price> </book> <book> <title id='2'>AJAX Tutorial</title> <author>Charles</author> <year>2007</year> <price>03.45</price> </book></bookstore> In this XML sample, the root node is <bookstore>.