Re: Replacing Node and ChildNodes with xml datas.
Brought to you by:
bs_php,
nigelswinson
From: James H. <ja...@oc...> - 2003-01-28 23:15:04
|
Eric, One thing that I have noticed with phpxpath is there is not any real=20 shortcuts, you have to read up on everything. Basically what you would=20= have to do is something like, <? if ($editnode=3D=3D1){ $newpath=3D$_GET["newpath"]; #what you passed from your form, in this case, telling you what node=20 you are dealing with ?> Now if you want to strip all your children and recreate new ones you can <? $xpath->removeChild($newpath); #this would remove BBB all together, then #you have to get your original node back, so you can $array=3Dsplit($newpath, "/");#check before you use, this might be some=20= incorrect split usage $newpath=3D"/".$array[1]; #which should give something like /aaa $newpath=3D$xpath->appendChild($newpath, $array[2], 0);#which should=20 create bbb again $xpath->setAttribute($newpath, "FOO", "bar", 0); } ?> This should get you started, if you have anymore problems, let me know.=20= So far I have written a firewall interface with xpath, that modifies=20= an xml file that will automatically update the firewall on the fly. If=20= you need additional help, it would help to know what type of results=20 you are trying to achieve, on what type of application. --James On Tuesday, Jan 28, 2003, at 16:31 America/New_York, Eric Wallet wrote: > Hello, > > I want to replace the content of a node and its childs node with a new=20= > xml content. > > For example : > <?Process_Instruction test=3D"=A9=A0All right reserved" ?> > <AAA FOO=3D"bar"> =A0=A0=A0=A0,,1,, ..1.. <![CDATA[ bla bla newLine = blo blo ]]>=20 > =A0=A0=A0 > <BB>Step 1. Insert new node</BB> =A0=A0=A0 > <BBB FOO=3D"bar"> =A0=A0=A0=A0=A0=A0=A0 > <CCC>Step 1. Append new node</CCC> =A0=A0=A0=A0=A0=A0=A0=A0..2.. = =A0=A0=A0=A0=A0=A0=A0 > <CCC>Step 2. Append new node</CCC> =A0=A0=A0=A0=A0=A0=A0 > <CCC>Step 3. Append new node</CCC> =A0=A0=A0 > </BBB> =A0=A0=A0=A0"Some new text"..3.. =A0=A0=A0 > <DDD>Replaced last BB</DDD> =A0=A0=A0 > <CC/> =A0=A0=A0=A0..4.. > </AAA> > > I would replace /AAA/BBB[@FOO=3D'bar'] by xml content .. > How can i do ? > > ReplaceData method just insert datas but doesn't replace subchilds... > please help me > Thanks > Eric > _____________________________________________________________________=20= > Envie de discuter en "live" avec vos amis ? T=C8l=C8charger MSN = Messenger=20 > http://www.ifrance.com/_reloc/m la 1=CBre messagerie instantan=C8e de=20= > France ------------------------------------------------------- This=20 > SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM +=20= > LinuxWorld =3D Something 2 See! http://www.vasoftware.com=20 > _______________________________________________ Phpxpath-users mailing=20= > list Php...@li...=20 > https://lists.sourceforge.net/lists/listinfo/phpxpath-users=20= |