xpath 节点集中有多少个元素
我有这个 matlab 函数:
function trackName = getTrackName(xpath, gpxSourceDom)
% Import the XPath classes
import javax.xml.xpath.*
% Compile the expression
expression = xpath.compile('gpx/trk/name');
% Apply the expression to the DOM.
trackNames = expression.evaluate(gpxSourceDom, XPathConstants.NODESET);
end
我需要一种方法来打印 trackNames
NODESET 中的每个元素。我怎样才能做到这一点?
I have this matlab function:
function trackName = getTrackName(xpath, gpxSourceDom)
% Import the XPath classes
import javax.xml.xpath.*
% Compile the expression
expression = xpath.compile('gpx/trk/name');
% Apply the expression to the DOM.
trackNames = expression.evaluate(gpxSourceDom, XPathConstants.NODESET);
end
I need a way to print every element inside trackNames
NODESET. How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
快速搜索 MATLAB 和 xpath 返回了以下结果:
在 matlab 中使用 xpath
您缺少的部分是迭代结果并显示名称。有关可以使用节点执行哪些操作的更多想法,请查看 javadoc。
对于 i = 1:nodeList.getLength
节点 = nodeList.item(i-1);
disp(char(node.getFirstChild.getNodeValue))
结束
A quick search of MATLAB and xpath returned this result:
using xpath in matlab
The part you're missing is iterating through the results and displaying the name. For more ideas of what you can do with the nodes, check out the javadoc.
for i = 1:nodeList.getLength
node = nodeList.item(i-1);
disp(char(node.getFirstChild.getNodeValue))
end