Re: SimpleXMLElement, adding nodes that are SimpleXMLElement.

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

 



On 25 July 2011 13:47, Richard Quadling <rquadling@xxxxxxxxx> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux