Skip to content
  • 0 Votes
    5 Posts
    469 Views
    J

    Thank you for your help (and for previous answers). Cheers, marking this completed.

  • 0 Votes
    3 Posts
    1k Views
    R

    Hi JonB, thanks for your quick response.

    In effect, I just want to get the values of (And that's how I do it):

    <applicationdisplayname> My Application Display Name </applicationdisplayname> <applicationhashkey> a9cd0d49e19637c0fea893d12ac87f64 </applicationhashkey> <applicationname> MyApplicationName </applicationname> . . .

    I already detected the problem that was presented to me, when I traversed the XML tree, each node converted it directly to QDomElement and that was where the error was located. Well, when comparing with

    element.nodeValue () .isEmpty ()

    The value thrown is the one mentioned in the first post, then I switched to QDomNode and when doing the same comparison I threw empty and additional to that allows me to go deeper into the tree and ask if it is a QDomText and better control my requirements.

    In short, the solution is to obtain the QDomDocument, go through each node of the XML tree as QDomNode and compare it with

    element.nodeValue () .isEmpty ()

    what you have told me happens

    @JonB said in how to determine an empty node with QDomNode:

    Are you thinking of:
    <app>
    some-arbitrary-text-here
    <applicationdisplayname>My Application Display Name</applicationdisplayname>

    That (some-arbitrary-text-here) is not going to happen. A node will either be a text node, containing text, or it will be an element which instead contains other child nodes. If by any chance that is what you are asking about.

    Thank you very much for your help and guidance.

  • 0 Votes
    3 Posts
    1k Views
    D

    Hi @Paul-Colby,

    Awesome!
    Now, I understand better what the Qt document wanted to say about this function.
    (Probably, an example in the doc would be useful.)

    It's a different question, but is there any way to move the xmlns attribute outside from this tag?
    (Example, If I would use more <fooelement> tags, it would be redundant to see this definition again.)

    Thanks a lot!

  • 0 Votes
    5 Posts
    2k Views
    mrjjM

    @Bart_Vandewoestyne said:

    QDomElement

    HI
    Since it stores it text as QStrings its pretty self contained so even
    doc is deleted the text should still be valid.

    One should imagine
    element = doc.documentElement() should point to invalid
    node after, but Im wondering if a copy is made.

    One test could be fun though
    http://doc.qt.io/qt-5/qdomnode.html#ownerDocument
    Should return a null node. (isNull returns true)

  • 0 Votes
    4 Posts
    7k Views
    A

    Like @Ratzz said. QXmlPutGet is very easy.

    QStringList list_IO; QXmlGet xml; xml.load(Sample.xml) xml.findAndDescend("General"); while(xml.findNext("IO") { list_IO = xml.getString(); } xml.rise();
  • 0 Votes
    1 Posts
    881 Views
    No one has replied