×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Jun 2007
    Location
    Jakarta, Indonesia
    Posts
    269

    Smile xml parsing : white space chars recognized as content

    Hi FN

    Thanks for the previous pointer xml parsing : the 2nd root tag isn't parsed

    I have another question to ask, in my new xml (like bellow)
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <sml>
        <draw>
    
        <span>Tove</span>
        
        </draw>
        
    <inditext>
    </inditext>
    </sml>
    The sml tag parsed OK, the span tag parsed OK too. But the inditext tag parsed with white space chars counted as content.

    So the OnContentL( const TDesC8 &aBytes, TInt aErrorCode ) is called twice.

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <sml>
        <draw>
    
        <span>Tove</span>
        
        </draw>
        
    <inditext>  -> OnContentL called here, the first newline char
    </inditext>  -> OnContentL called here, the 2nd newline char
    </sml>
    Why is this happening? In the previous tag it worked just fine ignoring the white space char


    PS: I checked the content by alerting the TDesC8 &aBytes and found it is white spaces (newline)
    Last edited by strike_noir; 2008-06-12 at 06:21.

  2. #2
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: xml parsing : white space chars recognized as content

    Its working as designed, what about the people that want a newline in their content?

    Either generate the xml with no whitespace or remove the characters manually before saving the element content.
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  3. #3
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: xml parsing : white space chars recognized as content

    yes, can u upload the xml, probably, it is working fine with previous case as there is only one new line, and in the second case, there are some space characters (other than newline) also !!!
    Amit Kankani
    Nokia Developer Champion

  4. #4
    Regular Contributor
    Join Date
    Jun 2007
    Location
    Jakarta, Indonesia
    Posts
    269

    Re: xml parsing : white space chars recognized as content

    Hi Paul & Amit


    Thank you very much for your time. I'm pretty confused myself in this issue. Currently I'm trying to solve this by reading my code over and changing the xml file.

    I will give report as soon as possible.

    Thank you

  5. #5
    Regular Contributor
    Join Date
    Jun 2007
    Location
    Jakarta, Indonesia
    Posts
    269

    Re: xml parsing : white space chars recognized as content

    Hi Paul & Amit


    Yes it seems what Paul said is true. I have a newline before the ending tag.

    Code:
    <tag>
    content           -> here is the newline
    </tag>
    I now learnt that the OnContentL method will return twice
    The first is the "content" string
    The second is the newline character

    The newline character is the culprit

    I changed the xml to
    Code:
    <tag>content</tag>
    The OnContentL is never called twice again.

    Thank you Paul & Amit
    Last edited by strike_noir; 2008-06-13 at 06:06.

  6. #6
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: xml parsing : white space chars recognized as content

    great ! i am sure now u will remember this as you tried it yourself

    however, you should build a wrapper around the xml parser in general, so that you can append the entire contents of a particular tag and have it shown and not depend on the correctness of xml always...

    i hope u got what i meant !
    Amit Kankani
    Nokia Developer Champion

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. Parsing Large XML Files
    By sandordornbush in forum Symbian
    Replies: 11
    Last Post: 2008-01-03, 10:00
  3. Replies: 4
    Last Post: 2007-08-10, 02:04
  4. Audio Input Stream on N80
    By tkaihock in forum Symbian Media (Closed)
    Replies: 9
    Last Post: 2006-06-30, 09:15
  5. XML Parsing
    By jessyjane in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2006-04-24, 08:17

Posting Permissions

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