It is currently Fri Jun 22, 2018 6:45 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: MoveXMLNode vs PreviousXMLNode
PostPosted: Fri Feb 23, 2018 11:24 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Sep 20, 2004 7:12 am
Posts: 465
Location: Hell
Code:
XML$ = "<aaa>" +
" <pos1 />" +
" <pos2 />" +
"</aaa>"

If CatchXML(0, @XML$, StringByteLength(XML$), 0, #PB_UTF8) And XMLStatus(0) = #PB_XML_Success
   *Root  = RootXMLNode(0)
   *aaa   = ChildXMLNode(*Root)
   *pos1  = ChildXMLNode(*aaa)
   *pos2  = NextXMLNode(*pos1)
   Debug PreviousXMLNode(*pos1) ;pos1 is the first child, so it will return 0, correct
   ;now switch pos1 and pos2
   MoveXMLNode(*pos2, *aaa, 0)
   ;test if pos2 is first now
   *test = ChildXMLNode(*aaa, 1)
   Debug GetXMLNodeName(*test) ;o.k.
   
   ;then there shouldn't be any previous node in front of pos2, right?
   Debug PreviousXMLNode(*pos2) ;???
EndIf

_________________
Link dead?
Change h3x0r.ath.cx into hex0rs.coderbu.de and all will be fine.


Top
 Profile  
Reply with quote  
 Post subject: Re: MoveXMLNode vs PreviousXMLNode
PostPosted: Mon Feb 26, 2018 12:28 am 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1553
Definitely a bug

Code:
XML$ = "<aaa>" +
" <pos1 />" +
" <pos2 />" +
"</aaa>"

CatchXML(0, @XML$, StringByteLength(XML$), 0, #PB_UTF8)
*aaa = MainXMLNode(0)

For i = 1 To 2
  *child = ChildXMLNode(*aaa, i)
  Debug "'" + GetXMLNodeName(*child) + "' [" + Hex(*child) + "]"
  Debug "^ Prev = " + Hex(PreviousXMLNode(*child))
  Debug "v Next = " + Hex(NextXMLNode(*child))
  Debug ""
Next i

Debug "----------------"
MoveXMLNode(ChildXMLNode(*aaa, 2), *aaa, 0)
For i = 1 To 2
  *child = ChildXMLNode(*aaa, i)
  Debug "'" + GetXMLNodeName(*child) + "' [" + Hex(*child) + "]"
  Debug "^ Prev = " + Hex(PreviousXMLNode(*child))
  Debug "v Next = " + Hex(NextXMLNode(*child))
  Debug ""
Next i


Top
 Profile  
Reply with quote  
 Post subject: Re: MoveXMLNode vs PreviousXMLNode
PostPosted: Mon Mar 19, 2018 8:58 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Sep 20, 2004 7:12 am
Posts: 465
Location: Hell
Just found another problem with MoveXMLNode(), maybe all depends on the same bug, I just want to make sure it will be fixed also:
Code:
XML.s = "<window>"   + #CRLF$
XML + " <vbox>"      + #CRLF$
XML + "  <button/>"  + #CRLF$
XML + "  <text/>"    + #CRLF$
XML + " </vbox>"     + #CRLF$
XML + "</window>"    + #CRLF$

If CatchXML(0, @XML, StringByteLength(XML), 0, #PB_Unicode)
   *Main        = MainXMLNode(0)
   *vbox_parent = ChildXMLNode(*Main)
   *text        = ChildXMLNode(*vbox_parent, 2)
   ;move text to first position
   MoveXMLNode(*text, *vbox_parent, 0)
   ;now delete text node
   DeleteXMLNode(*text)
   Debug "XMLChildCount() will now freeze!"
   Debug XMLChildCount(*vbox_parent)
EndIf


[Edit]
It seems all of those bad effects only happen, when you set *previousnode to zero => MoveXMLNode(*xxx, *yyy, -->0<--)

_________________
Link dead?
Change h3x0r.ath.cx into hex0rs.coderbu.de and all will be fine.


Top
 Profile  
Reply with quote  
 Post subject: Re: MoveXMLNode vs PreviousXMLNode
PostPosted: Tue Mar 20, 2018 1:19 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1553
Confirmed, and I'm sure fixing the first bug will fix this infinite loop second bug.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye