Writing Subchild with DOM
-
wrote on 9 Mar 2016, 07:22 last edited by
No error, It's just stuck, When i debuged it. I found it's stuck in the while loop.
-
wrote on 9 Mar 2016, 07:24 last edited by
@Aashu10 said:
No error, It's just stuck, When i debuged it. I found it's stuck in the while loop.
OK, so the code compiles.
I think you never go to the next node... it just reads forever and ever the first node of you document.
-
wrote on 9 Mar 2016, 07:28 last edited by
Any suggestion how to bypass this?
-
wrote on 9 Mar 2016, 07:46 last edited by
Well, at some point you must read you document, i.e. go from one node to the other. At the end of the loop you should do something like
domNode = domeNode.nextSibling()
. If you don't do so, you're endlessly reading the first node of your document, as I've told you before. -
wrote on 9 Mar 2016, 08:02 last edited by Aashu10 3 Sept 2016, 08:17
Ah! Thank you! @JohanSolo Now it goes through the loop properly, but the contents of the header is still empty. I just debugged, found out it never goes into
if(domElement.text() == "HEADER3")
I am not sure about hierarchy in the code. but the hierarchy in my XML file is as shown in this XML file
@JohanSolo I have edited the code accordingly
-
Ah! Thank you! @JohanSolo Now it goes through the loop properly, but the contents of the header is still empty. I just debugged, found out it never goes into
if(domElement.text() == "HEADER3")
I am not sure about hierarchy in the code. but the hierarchy in my XML file is as shown in this XML file
@JohanSolo I have edited the code accordingly
wrote on 9 Mar 2016, 08:17 last edited by JohanSolo 3 Sept 2016, 08:18 -
wrote on 9 Mar 2016, 08:32 last edited by Aashu10 3 Sept 2016, 08:32
Yes! @JohanSolo Now it goes inside the loop, but does not write the contents inside HEADER3. This time i have no idea why. I have updated the code. Please do take a look.
-
wrote on 9 Mar 2016, 09:46 last edited by JohanSolo 3 Sept 2016, 09:51
I don't see any obvious mistake. Note that I've never used QDomDocument to write a file. It's such a waste of memory according to me...
Edit: you should get a look at the returned value of
appendChild
to check that everything went fine. -
wrote on 9 Mar 2016, 10:09 last edited by
Thanks for replying, How do i check the return value of that. Sorry not so proficient with DomDocument.
-
Thanks for replying, How do i check the return value of that. Sorry not so proficient with DomDocument.
12/12