Connect and share knowledge within a single location that is structured and easy to search. I've temporarily removed the updating so I can debug the delete check.
This all works BUT it only removes the 1st delete and leaves all the other deletes even though it's a foreach loop??. Any help greatly appreciated. Deleting multiple times in the same iteration is unstable. SimpleXML node lists are plain arrays of references, and like with any deleting of items while forward iterating through an array, the array position pointer can get mixed up because the expected next item has disappeared.
Of course, if your other processing requires forward iterating through the elements, then using an array is the best. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?
Collectives on Stack Overflow. Learn more. Asked 8 years, 7 months ago. Active 3 months ago. Viewed 15k times. I've got a foreach loop that is only running once and it has me stumped. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 11 years ago. Active 10 years, 10 months ago. Viewed 7k times. Ofir Hadad Ofir Hadad 1, 3 3 gold badges 24 24 silver badges 44 44 bronze badges. Add a comment. Active Oldest Votes. Run code on Codepad.
Community Bot 1 1 1 silver badge. Gordon Gordon k 69 69 gold badges silver badges bronze badges. When you have navigated to the node you want to remove, it is possible to remove that node using the parentNode property and the removeChild method:.
It is not very common to use removeChild just to remove the text from a node. The nodeValue property can be used instead. See next paragraph. The removeAttributeNode method removes an attribute node, using the node object as parameter.
We just launched W3Schools videos.
0コメント