Using XPath from MATLAB
An XPath package started shipping as part of Java 5, so we can use it from MATLAB. This is a simple example.
The Java XPath API tutorial on ibm.com is a good introduction to XPath in Java.
% Import the XPath classes import javax.xml.xpath.* % Construct the DOM. doc = xmlread(which('demos/demos.xml')); % Create an XPath expression. factory = XPathFactory.newInstance; xpath = factory.newXPath; expression = xpath.compile('//demosection/label'); % Apply the expression to the DOM. nodeList = expression.evaluate(doc,XPathConstants.NODESET); % Iterate through the nodes that are returned. for i = 1:nodeList.getLength node = nodeList.item(i-1); disp(char(node.getFirstChild.getNodeValue)) end
Getting Started Mathematics Graphics 3-D Visualization Programming Desktop Tools and Development Environment Creating Graphical User Interfaces External Interfaces Gallery Other Demos New Features in Version 7