|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Updating and Deleting from XML
Started a new thread because the other one was kind of getting convoluted, I hope that's alright.
I think I am one or two small pieces away from wrapping my head around this, so a little help would be magnificient. I can create an XML file, and append to it using a form and a post page, I can pull the data back using xmlParse to get the data into an array like format. After finding examples I was able to pull the data back from the XMl page and turn it into a query format, which I can use SQL to pull off of, so I can display easily. The last pieces that I can't get my head around are updating and deleting. I know there are built in functions to handle these events, but I just can't find a good reference or example of how to utalize these functions. I've been checking my books and looking online, so any help would be huge. Thanks for all the help so far. |
|
#2
|
|||
|
|||
|
For updating and deleting, I would transform the data into an XML document object using xmlParse(), loop through it to handle your update or delete, and then save the entire thing back out as an XML file after you're finished.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Ahh, I was always getting my head stuck thinking "you're updating the structure, not the file how does that work"
But if I write the entire thing again to the file, then that should do it. I'll give it a shot, thanks. |
|
#4
|
|||
|
|||
|
Also at this point it might be wise to ask yourself if this data would be better handled within a relational database instead of XML. XML is great for configuration information or information that must be human readable and editable, but for actual data storage a database is much more applicable.
|
|
#5
|
|||
|
|||
|
I agree with you certainly, this is more just to learn how to deal with XML files, not for any practical reason, I would use a SQL Database way before I'd have even thought of this.
Still trying to get deleting working, updating works, but slightly different then how I think it "should" be. I pull the data, put it into a query and then doing selects on it, update via a form, and write to the file. I am trying to pull the data into a struct for a delete, but I can't seem to get it, can't find a good example...grrr. |
|
#6
|
|||
|
|||
|
If you just dump the XML document object you should see your data in an array and structure-like syntax. That should help you figure out how to delete an element.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Updating and Deleting from XML |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|