×

Discussion Board

Results 1 to 6 of 6

Thread: WRT XML Parser

  1. #1
    Registered User
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    WRT XML Parser

    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
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: WRT XML Parser

    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
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    Re: WRT XML Parser

    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
    Join Date
    Oct 2008
    Posts
    9

    Re: WRT XML Parser

    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
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: WRT XML Parser

    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
    Join Date
    Dec 2007
    Posts
    60

    Re: WRT XML Parser

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