1

I included an xml file to another that described in this answer https://stackoverflow.com/a/5127928/702642

Then I read it by using simplexml with below code

$mydom = new SimpleXMLElement(file_get_contents("myxml.xml"), LIBXML_NOENT);

//Do some changes in xml

$mydom->asXML("myxml.xml");

The problem is asXML function save all content to myxml.xml file like it never has a another included xml file. How can I save included xml and main xml files separately?

Community
  • 1
  • 1
ibrahim
  • 3,254
  • 7
  • 42
  • 56

1 Answers1

0

According to the PHP LibXML constants documentation, LIBXML_NOENT means "Substitute entities", so I think what's happening is that on load, the entity is being substituted in, and from then on, SimpleXML simply doesn't know it was an entity in the first place. So the answer would appear to be not to use that flag.

IMSoP
  • 89,526
  • 13
  • 117
  • 169
  • isn't there any alternative way to do that like using another parser etc.? – ibrahim Mar 24 '16 at 08:49
  • @ibrahim Well, it depends what is that you want to achieve exactly. It's not clear to me exactly what you're doing with this inner file, and why you want it expanded while editing but then not when saving. – IMSoP Mar 24 '16 at 09:51