在 Rhomobile 中使用 Xpath 时出错
我正在尝试使用 rexml Xpath 解析 XML,但在 rhomobile 应用程序中面临 const_missing: XPath 错误。谁能给我解决方案。
下面是示例代码: 文件 = File.new(文件名) 开始 需要“rexml/文档”
xmldoc = REXML::Document.new(file)
names = XPath.match(xmldoc, "//MP_HOST_NAME" )
I am trying to parse XML using rexml Xpath, but facing error as const_missing: XPath in rhomobile application. can anyone give me the solution.
Below is the sample code:
file = File.new(file_name)
begin
require 'rexml/document'
xmldoc = REXML::Document.new(file)
names = XPath.match(xmldoc, "//MP_HOST_NAME" )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的 build.yml 文件中:
如果使用黑莓,请将 rexml 替换为 rhoxml
假设您已完成此操作,请将您的 XPath 替换为:
in your build.yml file:
if using blackberry, replace rexml with rhoxml
Assuming you've done this, replace your XPath with:
这是我敲来测试 xml 解析的示例控制器
我可以在视图中使用 get_names 方法,然后获取名称数组
,确保在 build.yml 文件中设置 rhoxml,而不是 rexml,这样效果很好,而且速度更快
Here is a sample controller I knocked to test xml parsing
I can use the get_names method in the view then to get an array of names
ensure that rhoxml is set in the build.yml file rather than rexml this works fine and it's a little faster