Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » XML , DOM - Modify the tree
Re: XML , DOM - Modify the tree [message #12141 is a reply to message #12135] Fri, 12 October 2007 16:10 Go to previous messageGo to previous message
pippo is currently offline  pippo
Messages: 17
Registered: October 2007
Location: Italy
Promising Member
luzr wrote on Fri, 12 October 2007 11:44



You can use following methods to modify XmlNode:




YES! I've discovered these just 15 minutes ago... Smile
At() methods is very nice, also.

---
Now I need to swap 2 nodes with all their sub-nodes. And/or insert a node between other nodes in a precise position (no append at end).

BEFORE:
<EatInSequence>
   <module>
      <thing value= "spaghetti"/>
   </module>
   <module>
      <thing value= "pizza"/>
   </module>
   <module>
      <thing value= "cheese cake"/>
   </module>
</EatInSequence>

AFTER:
<EatInSequence>
   <module>
      <thing value= "spaghetti"/>
   </module>
   <module>
      <thing value= "Beer"/>
   </module>
   <module>
      <thing value= "pizza"/>
   </module>
   <module>
      <thing value= "cheese cake"/>
   </module>
</EatInSequence>


I CAN'T CHANGE ONLY THE VALUE OF ATTRIB "value" (my first idea Laughing), because this's only an exaple! In real my nodes are full of sub-nodes, then I must move sub and sub and sub nodes, too.

My onlyone solution found Embarassed is:
1) read the old xml file
2) in dom-tree insert a my tag with progressive number
3) insert new tags (in append...) and mark it with position number needed.
<EatInSequence>
   <module>
      <thing value= "spaghetti"/>
      <myTag progr = "0">
   </module>
   <module>
      <thing value= "pizza"/>
      <myTag progr = "2">
   </module>
   <module>
      <thing value= "cheese cake"/>
      <myTag progr = "3">
   </module>
   <module>
      <thing value= "beer"/>
      <myTag progr = "1">
   </module>
</EatInSequence>

4) create a new tree, copying the nodes in correct sequence and deleting my tags with progressive number.
5) save.
Embarassed

Have you got a better solution?


Sorry for my english.....




10aa3a8774daeb994a88cc07572e2b6c
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to read file into Memory
Next Topic: How to convert String to char ?
Goto Forum:
  


Current Time: Sat Aug 02 14:45:33 CEST 2025

Total time taken to generate the page: 0.09838 seconds