×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    15

    Thumbs up How to read text with tags inside from an xml file?

    Hi

    I've this xml:
    Code:
    <title>
     <p>Text with <b>bold</b> style</p>
    </title>
    I'm using QXmlStreamReader to parse the file but i've problems handling the <b> tags inside the text.


    This is my code:
    Code:
    if (reader.name().compare("p") == 0) {
        //this keeps the text but lost the <b> tags
        elementText = reader.readElementText(QXmlStreamReader::IncludeChildElements);
    
        //this omits <b> tags but i can't read the text inside <b> Any idea?
        //elementText = reader.readElementText(QXmlStreamReader::SkipChildElements);
    }
    I want keep the <b> with the text or detect it so I can handle.

    Is QXmlStreamReader the right tool?

    Thanks

  2. #2
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: How to read text with tags inside from an xml file?

    hi,
    readElementText() concatenates element text; "<B>" and "</B>" are element, not text!

    From my point of view for your need using QXmlStreamReader requires more work than using a simple regexps that capture the text between <p> and </p>
    If you want to use QXmlStreamReader than you have to have to create the string "elementText" (that you want to achieve)by yourself running a while to find the start elements, if the name() of the element is "p" then you have to use readNext to get the text (using isChar()) and name of the inner elements with name()..

Similar Threads

  1. Read XML config file
    By mary8 in forum Symbian
    Replies: 3
    Last Post: 2010-05-26, 15:24
  2. Read local xml file
    By mic3000 in forum Symbian
    Replies: 8
    Last Post: 2010-01-20, 15:22
  3. can we use form to read xml file ?
    By nokia_lin in forum Symbian User Interface
    Replies: 1
    Last Post: 2009-03-05, 12:48
  4. How to read XML file from Web
    By satheeshmd in forum [Archived] Flash Lite on Nokia Devices
    Replies: 1
    Last Post: 2009-02-09, 18:29
  5. Remove HTML tags from XML parsed text
    By sandro1972 in forum Mobile Java General
    Replies: 1
    Last Post: 2007-12-14, 10:13

Posting Permissions

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