Results 1 to 2 of 2

Thread: Setting the text in QDomElement

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2010
    Posts
    99
    Thanks
    31
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Setting the text in QDomElement

    Hi,

    I want to write XML file using QDomDocument. Firstly I am creating a document and then creating an element. The tagname() of the element is set, but am not able to set the text of the element. Is there any way I can do that.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Setting the text in QDomElement

    Quote Originally Posted by dpatel View Post
    Is there any way I can do that.
    Yes, by reading the documentation for QDomDocument for example At the end of the detailed description you found
    Qt Code:
    1. QDomDocument doc("MyML");
    2. QDomElement root = doc.createElement("MyML");
    3. doc.appendChild(root);
    4.  
    5. QDomElement tag = doc.createElement("Greeting");
    6. root.appendChild(tag);
    7.  
    8. QDomText t = doc.createTextNode("Hello World");
    9. tag.appendChild(t);
    10.  
    11. QString xml = doc.toString();
    To copy to clipboard, switch view to plain text mode 
    That should answer your question: QDomText!

  3. The following 2 users say thank you to Lykurg for this useful post:

    dpatel (4th May 2010), nirko (3rd December 2019)

Similar Threads

  1. QDomElement::text() returns corrupted strings
    By sladecek in forum Qt Programming
    Replies: 6
    Last Post: 7th March 2009, 14:07
  2. Setting the text of a QLineEdit
    By td in forum Newbie
    Replies: 2
    Last Post: 11th September 2008, 11:03
  3. Setting Max Limit in Text Box
    By kenny_isles in forum Newbie
    Replies: 4
    Last Post: 15th August 2007, 08:40
  4. setting text also changes color?
    By drhex in forum Qt Programming
    Replies: 5
    Last Post: 22nd November 2006, 16:36
  5. Setting text color on QLabel
    By Yorma in forum Newbie
    Replies: 11
    Last Post: 15th June 2006, 07:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.