Re: SimpleXMLElement, adding nodes that are SimpleXMLElement.
| From: | Richard Quadling | Date: | Mon, 25 Jul 2011 14:48:37 +0000 |
| Subject: | Re: SimpleXMLElement, adding nodes that are SimpleXMLElement. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-314197@lists.php.net to get a copy of this message | ||
On 25 July 2011 13:47, Richard Quadling <rquadling@gmail.com> wrote:
> Hello all.
>
> I've got 2 XML documents (one from a URL and another via MS SQL Server).
>
> The structure of these documents is the same, with just a difference
> in attribute to identify things (the 'data' is different but the
> variable's name attribute is the key here).
>
> <data>
> <variable name="var_name_x">
> <row>
> <column>data</column>
> ...
> </row.
> ...
> </variable>
> </data>
>
> I need to merge both documents so that the variable node of each
> document exists in a new document ...
>
> <data>
> <variable name="var_name_x">
> ...
> </variable>
> <variable name="var_name_y">
> ...
> </variable>
> </data>
>
> I know I can do this with string manipulation (and that's what I've
> done), but I'd like to use a more appropriate mechanism (part learning
> and part keeping the code tidy).
>
> I suspect SimpleXMLElement may not be the right tool.
>
> Richard.
Got it working when I finally discovered DOMDocument->importNode().
Allows the copying of a node from one DOM to another.
Easy.
--
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea