Hey guys,
I have a question about what I thought would be a simple task that has turned out to be more complicated than expected.
Basically I'm trying to slice an XML fragment from a larger XML document using xpath and then use that to create a new simplexml element. Sounds super but what I've been trying isn't working.
The trouble I seem to be having is that the result of an xpath query over a simplexml object is an array of elements and values which is fine but not what I need especially since the attributes are not preserved.
Here is some psuedo-code to pass on the basic idea of what I am wanting to do and if you can provide any help, I'd greatly appreciate it:
object = create simplexml object from source xml
slice = object->xpath(some xpath query)
result = slice as xml rather than an array
If this can't easily be done with simplexml and there is a better way to get the results I'm after, please let me know.
Thanks,
Chris
Start Free Trial