Re: modify xml file php script



Hi,

DOM should be your friend, for Documentation read this:

http://de2.php.net/manual/en/ref.dom.php

Have fun ..

Wolfgang

jp.delatorre@xxxxxxxxx wrote:
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: Saving dataset as nested XML
    ... my child is nested but I only received the duplicate ... > table, your code worked, and the resulting XML file had the data nested. ... > resulting schema from the file, and pasted it back into the XSD Editor. ... > parent and the child tables both contains the parent ID field, ...
    (microsoft.public.dotnet.xml)
  • Re: Saving dataset as nested XML
    ... I originally had the child table nested. ... table, your code worked, and the resulting XML file had the data nested. ... installing most likely SP1 help too. ... parent and the child tables both contains the parent ID field, ...
    (microsoft.public.dotnet.xml)
  • Re: Accessing parent controls in an MDI form fom the child forms by their name
    ... I.e. put the code to enable/disable child menu items in a handler for the parent menu's Popup event. ... 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)
  • Accessing parent controls in an MDI form fom the child forms by their name
    ... for example..i hav a menu in the parent form named "Administrator" whic ... has an item "mnuLogIn"..now when i click on login..another child form ... i hav an xml file whc has some database connectivity parameters, ...
    (microsoft.public.dotnet.general)
  • Re: Urgent : Displaying and managing data retreived with readxml
    ... child table by adding a new relationship to your dataset and defining the ... parent and foreign keys. ... > I am using readxml to retrieve data from an xml file to a dataset. ... > - A left menu witch will display the level 1 of my dataset data ...
    (microsoft.public.dotnet.languages.vb)