是否可以使用 Matlab 中的 xpath 读取、比较和查找 xml 文件中的特定字符串?我没有找到任何文档。
有人可以给我一个例子吗?
<?xml version="1.0" encoding="UTF-8"?>
<address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation='test.xsd'>
<lists name="myState">
<description name="-temp">-20</description>
<description name="localization">north</description>
<description name="-state">false</description>
</lists>
</address>
<language language="english" name="">
<description name="population">5000</description>
</language>
在这里访问 description name="localization"> ,我做了:
docNode = xmlread(myXMLFILE);
factory = XPathFactory.newInstance;
xpath = factory.newXPath;
% compile and evaluate the XPath Expression
expression = xpath.compile(adress/lists/description')
description = expression.evaluate(docNode, XPathConstants.NODE);
descriptionValue = phoneNumberNode.getTextContent % this gives me -20
我怎样才能得到价值?
谢谢