Results 1 to 3 of 3

Thread: QDom Issues

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question QDom Issues

    I am trying to write an XML file using QDomDocument. I have written files before with no issues, but I am trying something differently this time and am experiencing issues with this. I have a main application where I create the QDomDocument and fill in all the over-arching Metadata. I then have a library utility that is trying to write out QDomDocumentFragments to be added to the QDomDocument.

    So my heirarchy looks like this:

    Application creates QDomDocument --> calls container library to get QDomDocumentFragments --> container calls each item in the container which creates its own QDomDocumentFragment

    The container gathers all these Fragments into a QList and returns that to the application calling function which then loops through the list and appends these fragments onto the root node of the QDomDocument.

    The code is on a stand-alone network which is why I am not including it on here. If I need to, to help figure this problem out I will take the time to type it all in.

    So my application calls:

    Qt Code:
    1. QList<QDomDocumentFragment> trackFrags = container->toXml( );
    To copy to clipboard, switch view to plain text mode 

    The container creates this QList<QDomDocumentFragment> and loops through each track object stored in the container calling its own toXml function.

    It is inside this function where I have my issues. The code looks like something like:

    Qt Code:
    1.  
    2. QDomElement featureElem;
    3. featureElem.setTagName( "Feature" );
    4. frag.appendChild( featureElem );
    5.  
    6. QDomElement secondElem;
    7. secondElem.setTagName( "Second" );
    8. featureElem.appendCHild( secondElem );
    To copy to clipboard, switch view to plain text mode 

    I keep getting messages printing to my terminal window saying "Cannot append a child to a NULL node" or something real similar to that. So is there a way to do what I want to do without having to pass the QDomDocument down to these library classes? My hope was the library had to know nothing about the QDomDocument created by the application, but just create some fragments that could be passed from the library to the application and added to the document.

    This is just a stub of what I am trying to do which is why it looks like it contains no meat. Also, I am using Qt 4.7 on Solaris 10.

    Thanks for any help you have!
    Todd

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QDom Issues

    I think you have to use QDomDocument::createElement() to create appendable elements.

    What you could try is to use a local QDomDocument instance instead of passing in the actual one.

    Cheers,
    _

  3. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QDom Issues

    I will give the try with a local QDomDocument. Unfortunately there are no static members for QDomDocument so we'll see if the local document works or if I need to pass it in.

    Thanks!

Similar Threads

  1. Problem in QDom xml
    By wagmare in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2012, 20:52
  2. QDom & xhtml
    By Potch in forum Newbie
    Replies: 3
    Last Post: 19th February 2010, 23:41
  3. XML editing with QDom
    By trulysachin in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2008, 16:39
  4. QDom
    By mickey in forum General Programming
    Replies: 9
    Last Post: 17th September 2007, 16:12
  5. parsing using QDOM
    By aruna in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2007, 12:46

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.