gpt4 book ai didi

xml - 在 BlackBerry 上解析 XML 文件

转载 作者:数据小太阳 更新时间:2023-10-29 01:48:46 24 4
gpt4 key购买 nike

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

我在某处读到 JSON 是解析 xml 数据的好方法。

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

最佳答案

在黑莓中解析 XML

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

用 JSON 解析 XML

Blackberry 的 JSON 解析标准是 JSON ME

不知道...JSON 可以作为 XML 表示和传输,但反之则不行。

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 示例:

<?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 示例:

{
"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" }
]
}

基本上,如果您的 XML 是 JSON 的强等效项,例如:

<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>

可以使用 JSON 解析此类 XML。

关于xml - 在 BlackBerry 上解析 XML 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2757990/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com