【问题标题】:Parse XML Data in Arduino在 Arduino 中解析 XML 数据
【发布时间】:2016-10-08 05:54:12
【问题描述】:

我正在尝试使用对以下链接的 HTTP GET 请求从发布到网络的谷歌电子表格中读取 Arduino 中的 XML 数据。

https://spreadsheets.google.com/feeds/cells/SpreadsheetID/5/public/basic?&range=D10 我收到以下回复以及一些我可以在串口上观察到的标题。

我想解析上面回复中以粗体格式写的数据。数据可以是实数,可以是正数和负数。请帮助我找到解析这些数据的方法。

【问题讨论】:

    标签: c xml http parsing arduino


    【解决方案1】:

    你检查过这个库吗?

    https://web.archive.org/web/20160622041818/http://interactive-matter.eu/how-to/ajson-arduino-json-library/

    您最好将您的 XML 转换为 JSON,并考虑到 Arduino 上的内存可用性。

    否则,如果您真的想使用 XML,那么总会有这些资源:

    https://github.com/RobTillaart/Arduino/tree/master/libraries/XMLWriter

    http://john.crouchley.com/blog/archives/454

    【讨论】:

    【解决方案2】:

    如果你只需要一两个简单(超出参数)节点,你可以使用我的函数:)

    String xmlTakeParam(String inStr,String needParam)
    {
      if(inStr.indexOf("<"+needParam+">")>0){
         int CountChar=needParam.length();
         int indexStart=inStr.indexOf("<"+needParam+">");
         int indexStop= inStr.indexOf("</"+needParam+">");  
         return inStr.substring(indexStart+CountChar+2, indexStop);
      }
      return "not found";
    }
    

    我试图找到一个解决方案很长时间,为了清楚起见,把它留在这里。 已经有重复节点的复杂xml不会成功。

    【讨论】:

      猜你喜欢
      • 2015-04-02
      • 1970-01-01
      • 2012-12-19
      • 1970-01-01
      • 1970-01-01
      • 2020-08-04
      • 2015-07-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多