The XML plugin can parse and read data from XML documents. It uses XPath to access the XML document. XPath is a kind of query language for XML, similar to how SQL is a query language for databases. To learn more about XPath, see the following links:
W3Schools XPath tutorial
Some XPath examples
Another XPath tutorial with examples
Currently the XML plugin is read-only. You can read data but not change any values in the XML document.
For features in common to other plugins, see common features.
Loading an XML document
XML must be loaded as a string with the Load action. If you have a small snippet of XML, you can paste it directly in to the action parameter. However, it's recommended to request an XML file from a server using the AJAX object. When the AJAX request completes, pass AJAX.LastData in to the Load action. Now you can start reading the data that was received.
Internet Explorer does not support XPath queries that return a number, e.g. count(...). In this case you can use the NodeCount expression instead. Be sure to test your project works in a range of browsers, which is a best practice anyway. All other browsers have fully standards-compliant XPath support.
- For each node
- Repeat the event once for each node returned by an XPath query. Typically this will be used with a query that returns multiple nodes, e.g. "/bookstore/book" to select all "book" nodes under "bookstore". In the For each node event, the current node is set to the one currently being iterated. This means relative XPaths, like "title/text()", work relative to the current node (in this case returning the text of the child "title" tag). For each node can also be nested, so you can iterate another list relative to the current node.
- Load an XML document from a string. See 'Loading an XML document' above.
- Return the number of nodes returned by an XPath expression. For example, this can count the number of elements with a given name. In a For each node event, the XPath is relative to the current node.
- Return a number from an XPath expression. If multiple values are returned, only the first value is retrieved. In a For each node event, the XPath is relative to the current node.
- Return a string from an XPath expression. If multiple values are returned, only the first value is retrieved. In a For each node event, the XPath is relative to the current node.