php - check if the file exists, if not, create -
How do I use php dom, if an XML file exists, and it is not created.
AppendChild ($ newText); $ Xmldoc- & gt; Save ('sample.xml'); ? & Gt; Right now, because it does not exist, it gives me this error:
DOMDocument :: load (): I / O Warning: Failed External To load the unitDo not do this with the DOM, check it yourself:
If (file_exists ('sample.xml')) {$ xmldoc- & gt; Load ('sample.xml'); } And ($ xmldoc-> loadXML ('& lt; root / & gt;'); // or any other Routot name that attacks your fancy}file For savings will automatically be
$ xmldoc-> Save ();with the next.
Comments
Post a Comment