Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Replacing elements in XML Documents

Moderators: larsivi kris

Posted: 02/17/09 11:04:41

I've got a tango.text.xml.Document object. I need to update some of its contents. I start with using a filter query to find the element I'm interested in. That gives me a Node that I can play with.

What's an efficient way of just replacing most or all of the contents of that element and its children? Do I call detach on it and then add it back in? I could do a foreach over attributes and child elements, and replace each individual value, but I have a feeling a wholesale replacement could be faster.

I guess I could just dump the child elements (there are maybe 10 of them), and then add them back in. How would I do that?

Author Message

Posted: 02/17/09 13:43:45

I'm beginning to think that using XML as anything but a serialization format is more of a hassle than it's worth. Guess I've learnt something today too, then.