modify xml file php script



how to create script that modify xml file

sample xml file:

<root>
<parent name="a" id="1">
<child name="a.a" id="1.1" />
<child name="a.b" id="1.2" />
<child name="a.c" id="1.3" />
</parent>
<parent name="b" id="2">
<child name="b.a" id="2.1" />
</parent>
<parent name="c" id="3">
<child name="c.a" id="3.1" />
<child name="c.b" id="3.2" />
</parent>
</root>

php script should be able to modify the xml file. it should be able to
insert a parent element say between parent A and parent B. the id of
the new parent element should be parent B with its child respectively.
the parent elements below the new element should adjust the ids. in the
example above, parent B id should be 3 and its child id should be 3.1.
same goes to parent C and its childs.
result would be:
<root>
<parent name="a" id="1">
<child name="a.a" id="1.1" />
<child name="a.b" id="1.2" />
<child name="a.c" id="1.3" />
</parent>
<parent name="newparent" id="2">
<child name="newparent.a" id="2.1" />
<child name="newparent.b" id="2.2" />
</parent>
<parent name="b" id="3">
<child name="b.a" id="3.1" />
</parent>
<parent name="c" id="4">
<child name="c.a" id="4.1" />
<child name="c.b" id="4.2" />
</parent>
</root>

any comments on this...

.



Relevant Pages

  • Re: modify xml file php script
    ... php script should be able to modify the xml file. ... the new parent element should be parent B with its child respectively. ...
    (comp.lang.php)
  • Re: LINQ XML Determine Parent Node
    ... from parent in root ... from acfRef in parent ... select new ActivityReference ... you can just use "actRef.Parent" to retrieve the parent element of the "actRef" element. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Accessing parent controls in an MDI form fom the child forms b
    ... Also, your login screen would ... for example..i hav a menu in the parent form named "Administrator" whic ... i hav an xml file whc has some database connectivity parameters, ...
    (microsoft.public.dotnet.general)
  • Re: Is my Apache server running as the root user or not?
    ... parent runs as root so that it can attach to port 80. ... port 80, Apache will hand it off to a child process running as www. ... > one of the forks are runned as root and listening on port 80 as well as the other forks ...
    (FreeBSD-Security)
  • Re: Is my Apache server running as the root user or not?
    ... parent runs as root so that it can attach to port 80. ... port 80, Apache will hand it off to a child process running as www. ... > one of the forks are runned as root and listening on port 80 as well as the other forks ...
    (freebsd-questions)