Discussion Board

Results 1 to 6 of 6

Thread: WRT XML Parser

  1. #1
    Registered User bhanuchandar.k's Avatar
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868
    Hi,
    Is there any xml parser available for widgets Like Kxml parser for j2me ? I want to parse the xml . How do I do that?

  2. #2
    Nokia Developer Champion jappit's Avatar
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,391
    Hi Bhanu,

    if you want to get the XML structure of a document retrieved from an XMLHttpRequest call, you can directly access its responseXML object, containing the response complete XML tree.

    To parse an XML got in another way, you can:

    1) take the XML content as plain text
    2) create a fake (hidden) DIV
    3) set the innerHMTL property of the created div to the XML content

    Doing this way, you'll be able to access the complete XML structure by simply traversing the DIV DOM structure.

    Hope it helps,
    Pit

  3. #3
    Registered User bhanuchandar.k's Avatar
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868
    Hi jappit,
    Thanks for your reply . I have One more question How do I retrieve the xml Document from the XMLHttpRequest is there any example ?

  4. #4
    Nokia Developer Expert raghava.chinnappa's Avatar
    Join Date
    Oct 2008
    Posts
    9
    Hi,

    The response object from the XmlHttpRequest has these properties

    Code:
    // String version of data returned from server
    XmlHttpResponse.responseText
    
    // DOM-compatible document object of data returned from server
    XmlHttpResponse.responseXML
    responseXML itself is a DOM object, it's ready parse. But in case of responseText, use the method that @jappit mentioned on his reply.

    Thanks,
    Raghava

  5. #5
    Nokia Developer Champion jappit's Avatar
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,391
    Hi Bhanu,

    just follow the good tips given by Raghava.

    For some other useful infos and code, take a look here:

    * A complete introduction: http://ajaxpatterns.org/XMLHttpReque...#XML_Responses
    * Widget code using responseXML: http://wiki.forum.nokia.com/index.ph...in_WRT_widgets

    Pit

  6. #6
    Regular Contributor peppe@peppe.net's Avatar
    Join Date
    Dec 2007
    Posts
    60
    Quote Originally Posted by bhanuchandar.k View Post
    Hi,
    Is there any xml parser available for widgets Like Kxml parser for j2me ? I want to parse the xml . How do I do that?
    Just fetch the data with XHR and you can get the parsed DOM tree with the responseXML property of the XMLHttpRequest object. I.e. you don't need to explicitly parse anything - it's done for you.

    Peppe

Similar Threads

  1. Parsing wbxml file to xml file using kxml parser
    By ramyashashe in forum Mobile Java General
    Replies: 18
    Last Post: 2010-05-17, 15:56
  2. XML Parser in C++
    By mrinal_malhotra in forum Symbian C++
    Replies: 4
    Last Post: 2008-11-10, 13:22
  3. kXML XML Parser versus Jsr172 API Parser
    By javame.developer in forum Mobile Java General
    Replies: 1
    Last Post: 2008-02-14, 20:23
  4. Anybody ported TinyXML or Expat or some other XML parser?
    By doctordwarf in forum Symbian C++
    Replies: 2
    Last Post: 2003-11-10, 11:53
  5. Replies: 0
    Last Post: 2002-09-30, 15:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved