Re: [PHP] manipulating XML via php DOM
- From: peroc79@xxxxxxxxx ("pere roca ristol")
- Date: Wed, 21 Nov 2007 16:28:21 +0100
Jonas, that's what I want to get (and is valid).
Thanks,
....
<And>
<PropertyIsEqualTo>
<PropertyName>genus</PropertyName>
<Literal>ontophaugs332</Literal>
</PropertyIsEqualTo>
<Or>
<PropertyIsEqualTo>
<PropertyName>genus</PropertyName>
<Literal>ontophaugs332</Literal>
</PropertyIsEqualTo>
<PropertyIsEqualTo>
<PropertyName>genus</PropertyName>
<Literal>ontophaugs</Literal>
</PropertyIsEqualTo>
</Or>
</And>
....
2007/11/21, Jonas Geiregat <jonas@xxxxxxxxxxxx>:
I don't think it is valid to have an opening tag and a closing tag with
nothing in between. So an initial <or> and a final </or>, as you recall
it, should become <or/>.
Second, I'm not sure I understand what you want to accomplish. From the
example document you added is this the result you expect:
<And>
<PropertyIsEqualTo>
<PropertyName>genus</PropertyName>
<Literal>ontophaugs332</Literal>
</PropertyIsEqualTo>
<Or/>
<Or/>
</And>
Regards
Jonas
On Tue, 2007-11-20 at 10:27 -0800, pere roca wrote:
please, I need some help with php DOM, for me it's becoming a hell!"php
After trying other methods (check message from 19th november, called
DOM question"), I'm getting a little more success to manipulate XML.to
From the code you can see below you generate this xml. Now I just want
keep only the initial <Or> and the final </Or>. How can I access anddelete
the other (the "between" tags)?associated
I suppose there is no way to create an initial <Or> without the
</Or>.http://www.nabble.com/manipulating-XML-via-php-DOM-tf4845510.html#a13862945
Thanks a lot,
Pere
This is the WRONG XML generated from code.
...
<And>
<PropertyIsEqualTo>
<PropertyName>genus</PropertyName>
<Literal>ontophaugs332</Literal>
</PropertyIsEqualTo>
<Or>
<PropertyIsEqualTo>
<PropertyName>genus</PropertyName>
<Literal>copris</Literal>
</PropertyIsEqualTo>
</Or>
<Or>
<PropertyIsEqualTo>
<PropertyName>genus</PropertyName>
<Literal>copris2</Literal>
</PropertyIsEqualTo>
</Or>
</And>
<?php
$species=array('ontophaugs332','copris','copris2');
$dom = new DOMDocument;
//XML we will insert the data to
$dom -> load('edit_iberia3.xml');
$count=count($species);
foreach ($species as $sp=>$value) {
//we pass parameters of the array
$where_to_insert= $dom->getElementsByTagName('And')->item(0);
$child = $dom->createElement('Or');
$or=$where_to_insert->appendChild($child);
$child = $dom->createElement('PropertyIsEqualTo');
$first=$or->appendChild($child);
$child2 = $dom->createElement('PropertyName');
$first->appendChild($child2);
$child3 = $dom->createElement('Literal');
$first->appendChild($child3);
//inserting the array data
$values = $dom->createTextNode($value);
$values = $child3->appendChild($values);
}
echo $dom->save(nou_iberia);
?>
--
View this message in context:
Sent from the PHP - General mailing list archive at Nabble.com.
- References:
- [PHP] manipulating XML via php DOM
- From: pere roca
- Re: [PHP] manipulating XML via php DOM
- From: Jonas Geiregat
- [PHP] manipulating XML via php DOM
- Prev by Date: Re: [PHP] manipulating XML via php DOM
- Next by Date: Re: [PHP] Concurrency in a multi-user environment
- Previous by thread: Re: [PHP] manipulating XML via php DOM
- Next by thread: __sleep() strange behavior with file writting and SESSION using
- Index(es):