XSLT Transformation

In this tutorial, we will learn about how to transform XML into XHTML using XSLT. Correct StyleSheet Declaration: To declare the document to be an XSL style sheet, <xsl:stylesheet> or <xsl:transform> are used as the root element. Being completely synonymous, either of them can be used. According to the W3C XSLT Recommendation, the correct way … Read more

XSL(T) Languages

XSLT: The language for transforming XML documents. XPath: The language for navigating in XML documents. XQuery: The language for querying XML documents. Starting with XSL: XSL or EXtensible Stylesheet Language was developed by the World Wide Web Consortium, also known as W3C, as there was a necessity for an XML-based Stylesheet Language. CSS is the … Read more

XPath Examples

Books.xml: ABC Author Name 2020 29.99 XQuery Book Author 1 Author 2 2005 49.99 Loading the XML Document: To load the XML documents, we can use an XMLHttpRequest object. All modern browsers support it. Example: var xmlhttp = new XMLHttpRequest(); Selecting Nodes: In different browsers, there are different ways of dealing with XPath. Chrome, Firefox, … Read more

XPath Operators

A node-set, a string, a Boolean, or a number is returned by an XPath expression. The operators that we can use in XPath expressions are listed below: Operator Example Description | //book | //cd Computes two node-sets + 11 + 22 Addition – 22 – 11 Subtraction * 11 * 22 Multiplication div 22 div … Read more

XPath Axes

Example: ABC 100.00 IT Basics 300.00 XPath Axes: The relationship to the context (current) node is represented by an axis. The path axes are used to locate nodes relative to that node on the tree. AxisName Result ancestor To select all the ancestors (parent, grandparent, etc.) of the current node. ancestor-or-self To select all the … Read more

XPath Syntax

To select nodes or node-sets in an XML document, the path expressions are used by XPath, i.e., by following a path or steps, a node is selected. Example: ABC 100 XML Basics 300 Selecting Nodes: To select nodes or node-sets in an XML document, the path expressions are used by XPath, i.e., by following a … Read more

XPath Nodes

XPath Terminology: Nodes: The element, attribute, text, namespace, processing-instruction, comment, and document nodes are the seven kinds of nodes in XPath. The trees of nodes are the XML documents, and the root element is the topmost element of the tree. Example: ABC Author Name 2020 100 Explanation: The nodes in the above XML document are: … Read more

XML DOM Clone Nodes

To create a copy of a specified node, we use the cloneNode() method. The parameter of the cloneNode() method can either be true or false, thus indicating if all the attributes and child nodes of the original node should be included in the cloned node or not. Books.xml: ABC Author Name 2020 29.99 Basics Author … Read more

XML DOM Add Nodes

We can add a child node to an existing node using the appendChild() method. The addition of the new node is done only after any existing child nodes. If we need to specify the position of the node, we can use the insertBefore() method. Books.xml: ABC Author Name 2020 29.99 Basics Author 1 Author 2 … Read more

XML DOM Create Nodes

To create a new element node, we can use the createElement() method. Books.xml: ABC Author Name 2020 29.99 Basics Author 1 Author 2 2005 49.99 Example: Output: Explanation: In the above example, we are loading “books.xml” in the xmlDoc. We will then create a new element node <publisher> to append it to the first <book> … Read more