×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2006
    Location
    Beijing, China
    Posts
    1,175

    xml parsing problem when using xml framework

    hi,

    The following xml data will cause a panic(User 24) when parsing. (I tested it in AddressBook example)

    Code:
    void CAddressBookAppUi::TestParsingL()
    	{
    	_LIT8(kTestData, "<info>"
    			"<id>tom@yoursite.com</id>"
    			"<link rel='self' type='application/atom+xml'"
    			" href='http://www.yoursite.com/abc/tom%40yoursite.com/test?max=5' />"
    			"</info>");
    	MSenServiceConsumer* consumer = iEngine;
    	consumer->HandleMessageL(kTestData);
    	}
    If you change "%40" into '@' in the value of href(see above), that is,
    href='http://www.yoursite.com/abc/tom@yoursite.com/test?max=5'
    this test goes smoothly.

    Other code snippet: add log in CAddressBookEngine::StartElementL to see attributes of the current xml element.
    Code:
    void CAddressBookEngine::StartElementL(	const TDesC8& aNsUri,
    										const TDesC8& aLocalName,
    										const TDesC8& aQName,
    										const RAttributeArray& aAttrs)
    	{
    	_LIT( KStartElementL, "CAddressBookEngine::StartElementL() ***");
    	_LIT( KNamespaceURI, "- namespace URI  (%S)");
    	_LIT( KLocalname, "- localname      (%S)");
    	_LIT( KQualName, "- qualified name (%S)");
    	_LIT( KAttrName, "- attribute name (%S)");
    	_LIT( KAttrValue, "- attribute value (%S)");
    
    	LOG( KStartElementL);
    	LOG_FORMAT((KNamespaceURI, aNsUri));
    	LOG_FORMAT((KLocalname, aLocalName));
    	LOG_FORMAT((KQualName, aQName));
    
    	for (TInt i=0; i<aAttrs.Count(); ++i)
    		{
    		const RAttribute& attr = aAttrs[i];
    		LOG_FORMAT((KAttrName, attr.Attribute().LocalName().DesC()));
    		LOG_FORMAT((KAttrValue, attr.Value().DesC()));   // this line will cause panic when the attribute name is 'href'
    		}
    
       ...
    Is this a bug?
    Way of Simplicity

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: xml parsing problem when using xml framework

    i suggest you URLEncode the URL.

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

    Re: xml parsing problem when using xml framework

    It is URL-encoded already. Apparently LOG_FORMAT results in some code which - in its final step - feeds the string to be logged into some format-aware method. And the error message is true "%40 " is not a valid format string. It is a problem of the logger itself, so you can either fix it via creating a copy of what it should log and replace/extend '%'-s in it (replace with some neutral character, or extend it to "%%"), or just quickly check if it contains '%' and if it does, skip logging of the given value.

  4. #4
    Registered User
    Join Date
    Apr 2006
    Location
    Beijing, China
    Posts
    1,175

    Re: xml parsing problem when using xml framework

    You are right, thank you and your explanation. Xml framework itself is without problem.
    Way of Simplicity

Similar Threads

  1. Load online XML problem: Device vs. Device Central
    By davyhoskens in forum [Archived] Flash Lite on Nokia Devices
    Replies: 7
    Last Post: 2010-11-09, 04:00
  2. Replies: 12
    Last Post: 2010-03-21, 19:25
  3. XML Parsing problem - NanoXML and Netbeans
    By debayandas in forum Mobile Java General
    Replies: 0
    Last Post: 2009-07-22, 20:05
  4. Parsing xml file on nokia 6630
    By Transalp in forum Mobile Java General
    Replies: 0
    Last Post: 2008-04-25, 16:00
  5. xml parsing & CMDXMLParser
    By morost in forum Symbian
    Replies: 0
    Last Post: 2006-10-25, 16:56

Posting Permissions

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