# simplexml and dom

- Thread: https://externals.io/message/12632
- Original archive: https://news-web.php.net/php.internals/12632
- Started by Greg Beaver on 2004-09-07T17:27:49+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #12632 — Greg Beaver — 2004-09-07T17:27:49+00:00

URL: https://externals.io/message/12632#12632

Hi,

I've been experimenting with using both simplexml and dom on the same 
document at the same time, and have run into a number of unexplainable 
PHP crashes unless I clone the domdocument object before using 
 `simplexml_import_dom()`

Is it a design goal of simplexml to be able to use it simultaneously 
with dom, or is it important to use either a simplexmlelement or a 
domdocument for the same structure but not both?  If so, I will add a 
note to the manual, but I wanted to check with the creators first.

A simplified version of the code I use is something like:

<?php
$blah = 'xml stuff'; // this is actually the contents of a package.xml 
extracted from disk
$d = new DOMDocument;
$d->loadXml($blah); // I do error checking here
$sx = simplexml_import_dom($d);
// manipulate document structure using dom
// retrieve values using simplexml for simple tags
?>

Thanks,
Greg

---

## #12639 — Rob Richards — 2004-09-07T23:26:18+00:00

URL: https://externals.io/message/12632#12639 · In reply to: #12632

The goal is to be able to use it simultaneously.
Can you file a bug report and include code that produces the crash?

Rob

----- Original Message ----- 
From: Greg Beaver

> I've been experimenting with using both simplexml and dom on the same 
> document at the same time, and have run into a number of unexplainable 
> PHP crashes unless I clone the domdocument object before using 
> `simplexml_import_dom()`
> 
> Is it a design goal of simplexml to be able to use it simultaneously 
> with dom, or is it important to use either a simplexmlelement or a 
> domdocument for the same structure but not both?  If so, I will add a 
> note to the manual, but I wanted to check with the creators first.

---

## #12640 — Greg Beaver — 2004-09-07T23:50:01+00:00

URL: https://externals.io/message/12632#12640 · In reply to: #12639

Rob Richards wrote:
> The goal is to be able to use it simultaneously.
> Can you file a bug report and include code that produces the crash?
> 
> Rob

Sure, it's complicated code, so I'll try to get it all into 1 file and 
under 20 lines.

Greg
