×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 24

Thread: XML parsing

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    14

    Post XML parsing

    Hi,
    I'm using HttpClient Example and xmlexample for my sample and invoking post method and my response is in xml format.How do i parse my response xml to retrieve particular element .
    Kinldy share if u have any better code for this understanding.
    thanks in advance
    Senthilv

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,173

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: XML parsing

    For seeing how the parser itself works, you can check my example in #24 of http://discussion.forum.nokia.com/fo...in-xml-Parsing
    It is a SAX parser, for tracking your location in the XML tree, you will need some state machine. #21 in the same thread points to 3 posts which may be called an example.
    For a DOM-like parser you can use some CSen* classes, like CSenDomFragment.

  4. #4
    Registered User
    Join Date
    Apr 2011
    Location
    Hyderabad, IN
    Posts
    36

    Post Re: XML parsing

    Your code for XML parsing helped me very much. I have some queries like
    1) where I have to put the html code i.e

    <ComboBox name="Sex">
    <ListItem value="M" text="Male" selected="true" />
    <ListItem value="F" text="Female" />
    <ListItem value="F" text="Female" />
    </ComboBox>


    2)Where to write and what to write in if condition


    void CXmlHandler::OnStartElementL( const RTagInfo& aElement,
    const RAttributeArray& /*aAttributes*/, TInt aErrorCode )
    {
    if ( KErrNone == aErrorCode )
    {
    // Found start of an element, for example: "<tag>"
    // The name of the element is stored in aElement.LocalName().DesC().

    // Do something with the start of an element.
    }
    else
    {
    // Do something if error happens.
    }
    }


    3) what should be our final target or output
    Last edited by srk2011; 2011-04-14 at 09:11.

  5. #5
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,356

    Re: XML parsing

    You can get some idea from this below code,
    Code:
    void CXmlHandler::OnStartElementL( const RTagInfo& aElement,
            const RAttributeArray& aAttributes, TInt aErrorCode )
        {
        if ( KErrNone == aErrorCode )
            {
                                  
                                     
                                     
    //================================Code Start for Combo Box ====================================
            _LIT8(KMatchCombo,"ListItem");
                  
                   if(aElement.LocalName().DesC().Compare(KMatchCombo)==0)
                   	{
                  
                   	
                  	_LIT(message,"Combo Parsed !");
                   	CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
                   	informationNote->ExecuteLD(message); 	
                   	}
                   	
                               
                 
                               		  
                   for(TInt i=0;i<aAttributes.Count();i++)
                   	{
                   	const TDesC8 &name=aAttributes[i].Attribute().LocalName().DesC();
                   	const TDesC8 &value=aAttributes[i].Value().DesC();
                   	
                   
           					
                   	
                   	
                   	if(aElement.LocalName().DesC().Compare(KMatchCombo)==0)
                   		{
                   		
                   		
                   		
                   		_LIT8(KMatchCombo2,"text");
                   		/*_LIT(message,"Compare Functio !");
                            CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
                              informationNote->ExecuteLD(message);*/
                                   			                 			                  	  
                   			
                   			
                   		if(name.CompareF(KMatchCombo2)==0)
                   			{
                   			 // store the value into array , create you own array
                   			strComboBox[NumberofElementsComboBox].iHBbuf = HBufC::NewL(15);
                   			strComboBox[NumberofElementsComboBox].iHBbuf=CnvUtfConverter::ConvertToUnicodeFromUtf8L(value);
                   			//str[i].iHBbuf =iText;
                   			iArrayComboBox.Append(strComboBox[NumberofElementsComboBox]);
                   					
           				
                   			NumberofElementsComboBox++;
                   			
                   	
                   			
                   			
                   			
                   			  				    
                   			/*_LIT(message,"Data Matched !");
                   			CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
                   			informationNote->ExecuteLD(message);*/
                   		    
                   			
                   			
                   	
                   								            					
                   			}   
                   		}
                                                		              		 
                                   		  		
                                   		                       		  
                   	} 
            
    // =============================== Code Ends for Combo Box ====================================        
                                 
            AppendTag( aElement.LocalName().DesC(), EFalse );
            }
        else
            {
            iObserver.OnParseCompleted( aErrorCode );
            }
        
        }
    Last edited by somnathbanik; 2011-04-13 at 10:05. Reason: added

  6. #6
    Registered User
    Join Date
    Apr 2011
    Location
    Hyderabad, IN
    Posts
    36

    Post Re: XML parsing

    Hi my task is to parse the xml nodes containing channel
    name, Channel image and channel URL and create dynamic list for the channels. .Please help me it is very urgent . I have posted whole xml nodes in the earlier post..Try to email me atleast.
    srk2011

  7. #7
    Registered User
    Join Date
    Apr 2011
    Location
    Hyderabad, IN
    Posts
    36

    Re: XML parsing

    are u busy Iam waiting for reply to my post/ question regarding xml parsing.
    srk2011

  8. #8
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,356

    Re: XML parsing

    if you are talking about the xml in post #4 then the code in post#5 will help you to parse the xml, are you looking for any example.
    Please let me know what have you tried after post #5

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: XML parsing

    Just created a related article on http://avalon.aut.bme.hu/~wizard

  10. #10
    Registered User
    Join Date
    Apr 2011
    Location
    Hyderabad, IN
    Posts
    36

    Re: XML parsing

    Iam unable to parse the xml. Just give me simple code for parsing a simple xml script atleast or else please tell me where Iam wrong why Iam getting a blank page after running

    the app Iam testing on nokia5th edition tool or emulator (carbide c++) where our exact xml script will be?
    srk2011

  11. #11
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,173

    Re: XML parsing

    Iam unable to parse the xml. Just give me simple code for parsing a simple xml script atleast or else please tell me where Iam wrong why Iam getting a blank page after running
    What you have tried so far? Can you show your code here?

  12. #12
    Registered User
    Join Date
    Apr 2011
    Location
    Hyderabad, IN
    Posts
    36

    Re: XML parsing

    yes

    I tried the XmlHandler.cpp
    XmlHandler.h as shown in " How to parse xml using Cparse in this nokia forums . I can send total code to ur email id too.

  13. #13
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,173

    Re: XML parsing

    Quote Originally Posted by srk2011 View Post
    yes

    I tried the XmlHandler.cpp
    XmlHandler.h as shown in " How to parse xml using Cparse in this nokia forums . I can send total code to ur email id too.
    You can mention here your problem and the code as well.

  14. #14
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,356

    Re: XML parsing

    Quote Originally Posted by srk2011 View Post
    yes

    I tried the XmlHandler.cpp
    XmlHandler.h as shown in " How to parse xml using Cparse in this nokia forums . I can send total code to ur email id too.
    The full example is there in this article down below http://wiki.forum.nokia.com/index.ph..._CParser_class , have you tried that, it will parse the xml.
    Even if you are still confuse then share the XML doc that you are trying to parse.

  15. #15
    Nokia Developer Moderator
    Join Date
    Oct 2006
    Location
    Finland
    Posts
    4,539

    Re: XML parsing

    Quote Originally Posted by srk2011 View Post
    yes

    I tried the XmlHandler.cpp
    XmlHandler.h as shown in " How to parse xml using Cparse in this nokia forums . I can send total code to ur email id too.
    Can you please be more specific on what you tried so that you stand a chance to be helped. Also here is a little guideline to help you get proper guidance faster http://wiki.forum.nokia.com/index.ph...lp_for_dummies

Similar Threads

  1. Xml Parsing
    By sumeshchakra in forum Mobile Java General
    Replies: 2
    Last Post: 2010-04-29, 15:57
  2. Replies: 12
    Last Post: 2010-03-21, 19:25
  3. Replies: 3
    Last Post: 2009-08-20, 02:27
  4. XML parsing
    By veekay_a in forum Symbian
    Replies: 4
    Last Post: 2008-07-24, 11:36
  5. Need knowledge about XML and XML Parsing
    By 02060515 in forum Mobile Java General
    Replies: 1
    Last Post: 2008-07-07, 08:41

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×