Parse XML file on BlackBerry

后端 未结 4 671
执笔经年
执笔经年 2020-12-01 15:17

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

4条回答
  •  忘掉有多难
    2020-12-01 16:06

    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:

    
    
      Foligno Madonna, by Raphael
      This is Raphael's "Foligno" Madonna, painted in
        15111512.
      
    
    

    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:

    
      John
      Smith
      25
      
    21 2nd Street New York NY 10021
    212 555-1234 646 555-4567

    there is a possibility to parse such XML with JSON.

提交回复
热议问题