解析黑莓XML文件 [英] Parse XML file on BlackBerry

查看:237
本文介绍了解析黑莓XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何解析在BlackBerry XML数据。

我读的地方,JSON是解析XML数据的好方法。

是否有任何教程来解析XML数据使用JSON或任何其他机制?


解决方案

解析XML在黑莓


  

有关XML(SAX)简单API是由公共邮件列表的成员开发的(XML-DEV)。它给出了一个基于事件的方法解析XML。这意味着,而不是从节点将节点,它从事件进入事件。 SAX是一种事件驱动的接口。活动包括XML标记,检测错误等,
  J2ME SAX - 见<一href=\"http://stackoverflow.com/questions/2451356/blackberry-j2me-sax-parse-collection-of-objects-with-attributes\">BlackBerry/J2ME - 带属性的对象SAX解析集合


  
  

XML解析器拉 - 这是最适合需要快速的应用程序和一个小的XML解析器。它时,应使用的所有过程都必须快速而有效地进行,以输入元件
  使用kXML - J2ME拉解析器 - 见<一href=\"http://stackoverflow.com/questions/877428/better-approach-for-xml-creation-in-blackberry\">Better在黑莓 XML创建方法


解析XML与JSON

有关JSON解析黑莓标准是<一个href=\"http://stackoverflow.com/questions/1470406/how-to-parse-the-json-response-in-blackberry-j2me\">JSON ME

没有想法... JSON可以重新presented和运输为XML,而不是相反。


  

XML(可扩展标记语言)是用于电子地编码的文件的一组规则。它是由W3C和其他一些相关的规范,所有免费开放的标准生成的XML 1.0规范定义的。


XML示例:

 &LT;?XML版本=1.0编码='UTF-8'&GT?;
&LT;&绘画GT;
  &LT; IMG SRC =madonna.jpgALT =弗里诺麦当娜,拉斐尔'/&GT;
  &LT;标题&gt;这是拉斐尔的弗里诺麦当娜,涂在
    &LT;日期和GT; 1511&LT; /日期和GT; - &LT;日期和GT; 1512&LT; /日期取代。
  &LT; /字幕&GT;
&LT; /绘画&GT;


  

JSON(JavaScript的对象符号的缩写)是一个轻量级的基于文本的开放标准设计为人类可读的数据交换。它是从JavaScript编程语言重新presenting简单的数据结构和关联数组得出,(在JSON中的O)调用的对象。尽管它为JavaScript的关系,它是独立于语言,与现有的解析器几乎每一个编程语言。


JSON示例:

  {
     名字:约翰,
     姓氏:史密斯
     时代:25,
     地址: {
         的StreetAddress:21街2号,
         城市:纽约,
         状态:NY,
         邮政code:10021
     },
     电话号码: [
         {类型:家,数字:212 555-1234},
         {类型:传真,数:646 555-4567}
     ]
 }

基本上,如果你的XML是JSON强烈的等价,如:

 &LT;&人GT;
  &LT;&的firstName GT;约翰和LT; /&的firstName GT;
  &LT;&lastName的GT;史密斯和LT; / lastName的&GT;
  &LT;年龄&GT; 25℃/年龄&GT;
  &LT;地址&gt;
    &LT;&的StreetAddress GT; 21街2号&LT; /&的StreetAddress GT;
    &LT;城市&GT;纽约&LT; /城市&GT;
    &LT;州及GT; NY&LT; /州&GT;
    &LT;邮政code&GT; 10021&LT; /邮政code&GT;
  &LT; /地址&gt;
  &LT; phoneNumber的类型=家&GT; 212 555-1234&LT; / phoneNumber的&GT;
  &LT; phoneNumber的TYPE =传真&GT; 646 555-4567&LT; / phoneNumber的&GT;
&LT; /人&GT;

有可能解析这样的XML使用JSON

I want to know how to parse XML data on a BlackBerry.

I read somewhere that JSON is good method to parse xml data.

Are there any tutorials to parse XML data using JSON, or any other mechanism?

解决方案

Parsing XML in Blackberry

Simple API for XML (SAX) was developed by the members of a public mailing list (XML-DEV).It gives an event based approach to XML parsing. It means that instead of going from node to node, it goes from event to event. SAX is an event driven interface. Events include XML tag, detecting errors etc, J2ME SAX - see BlackBerry/J2ME - SAX parse collection of objects with attributes

XML pull parser - It is optimal for applications that require fast and a small XML parser. It should be used when all the process has to be performed quickly and efficiently to input elements kXML - J2ME pull parser - see Better approach for XML Creation in Blackberry

Parsing XML with JSON

Blackberry standard for JSON parsing is JSON ME

No idea... JSON can be represented and transported as a XML, but not vice versa.

XML (Extensible Markup Language) is a set of rules for encoding documents electronically. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards.

XML sample:

<?xml version="1.0" encoding='UTF-8'?>
<painting>
  <img src="madonna.jpg" alt='Foligno Madonna, by Raphael'/>
  <caption>This is Raphael's "Foligno" Madonna, painted in
    <date>1511</date>–<date>1512</date>.
  </caption>
</painting>

JSON (an acronym for JavaScript Object Notation) is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects (the "O" in "JSON"). Despite its relationship to JavaScript, it is language-independent, with parsers available for virtually every programming language.

JSON sample:

{
     "firstName": "John",
     "lastName": "Smith",
     "age": 25,
     "address": {
         "streetAddress": "21 2nd Street",
         "city": "New York",
         "state": "NY",
         "postalCode": "10021"
     },
     "phoneNumber": [
         { "type": "home", "number": "212 555-1234" },
         { "type": "fax", "number": "646 555-4567" }
     ]
 }

Basically if your XML is a strong equivalent of JSON, like:

<Person>
  <firstName>John</firstName>
  <lastName>Smith</lastName>
  <age>25</age>
  <address>
    <streetAddress>21 2nd Street</streetAddress>
    <city>New York</city>
    <state>NY</state>
    <postalCode>10021</postalCode>
  </address>
  <phoneNumber type="home">212 555-1234</phoneNumber>
  <phoneNumber type="fax">646 555-4567</phoneNumber>
</Person>

there is a possibility to parse such XML with JSON.

这篇关于解析黑莓XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆