-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document traverse works only once #49
Comments
Hello, Thanks for reporting. Would you mind adding a code example? |
I've already deleted the traversal and went with xpath query and calling remove directly there on the node list:
But I can see that there's no test for deep nested traversal and/or remove node action: https://github.com/veewee/xml/blob/main/tests/Xml/Dom/Traverser/TraverserTest.php. Simply adjusting the node's attributes, tag or contents works fine as it's just traversing and mutating the objects, but returning remove node action will only work once. What I was trying to do is remove all empty nodes in the xml like |
I'm still confused to be honest. The code you pasted is not recursive either. As you can see, the xpath should go in a loop. |
Yes, but via xpath I'm just pulling all the empty nodes and removing them. It actually worked for me. 🙈
Thank god, I was looking for this in the wrong place.
Yes, this is mutating the node sort of in-place. But if you were to replace it with |
@rauanmayemir Thanks for reporting! I found the issue in #50 ! |
Can confirm now it works as expected. 💃 I would still rather use |
Nice to hear! |
I was trying to
traverse
the document tree and delete empty nodes, but it only works once. I.e it does traverse the document, finds all the node elements I need, but deletes only the first one it sees, discarding everything else.I've checked the unit tests for
Action\RemoveNode
, and it only tests the deletion of the first attribute.The text was updated successfully, but these errors were encountered: