这是我的 XML 文档的示例,其中显示了网站站点地图
<?xml version="1.0" encoding="UTF-8"?>
<project name="Esurance 365 Portal">
<elements>
<element name="folderone" path="forms/folderone">
<folder function="model">models</folder>
<folder function="controller">controllers</folder>
<folder function="view">views</folder>
</element>
</elements>
</project>
我想使用DOMDocument
在图示的上方添加另一个元素节点,使其如下所示
<?xml version="1.0" encoding="UTF-8"?>
<project name="Esurance 365 Portal">
<elements>
<element name="foldertwo" path="forms/foldertwo">
<folder function="model">modelstwo</folder>
<folder function="controller">controllerstwo</folder>
<folder function="view">viewstwo</folder>
</element>
<element name="folderone" path="forms/folderone">
<folder function="model">models</folder>
<folder function="controller">controllers</folder>
<folder function="view">views</folder>
</element>
</elements>
</project>
但是从DOMDocument
文档中我似乎甚至找不到一个向我展示如何实现新元素的示例。
createElement
and方法只告诉我如何插入元素节点,appendChild
而不是如何插入剩余的文件夹子节点。