Re: [xml] Getting element content non-recursively



Caroline Middlebrook wrote:
Hi Rush,


This actually sounds like a job for XSLT. Have you not taken that
approach for a particular reason?
- Rush


Yes, I am using a C++ library that has been written by somebody else in my
company. I can make small additions to it but nothing major. The library is
just a C++ wrapper around libxml, and doesn't support XSLT or any other XML
technologies.


Well, that's too bad. I have to admit that I don't quite see what you're doing, but I will offer one idea to think about. Would it help you to first iterate over all the elements in document order and save pointers to them in a vector, then go through the vector in reverse order to do your replacements? That would mean that you replace contents of the most highly nested elements first. I have an application that needs to replace attributes on certain elements, and that is the way I do it. When I get the contents of a node, I get all the nested content too, including whatever I may have changed already.

- Rush



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]