tag:forum.selfhtml.org,2005:/selfFrage zu DOM-XML – SELFHTML-Forum2007-02-01T11:12:35Zhttps://forum.selfhtml.org/self/2007/feb/1/frage-zu-dom-xml/1074347#m1074347Sebastiankosmos1@gmx.net2007-02-01T11:12:35Z2007-02-01T11:12:35ZFrage zu DOM-XML<p>Hallo!</p>
<p>Ich habe eine XML-Struktur, die ungefähr so aussieht:</p>
<p><locations><br>
<location a="1" b="2"><br>
<title>Lokation 1</title><br>
<irgendeinTag>abc</irgendeinTag><br>
<subRegions sr_a="0" sr_b="1" sr_c="0" /><br>
</location><br>
</locations></p>
<p>gehe ich mit</p>
<p>$locations = $xpath->query( "//location" );</p>
<p>foreach( $locations as $location ) { }</p>
<p>die einzelnen Locations durch. Die Variable $subregion enthält einen beliebigen String (z.B. sr_a oder sr_y).</p>
<p>Nun will ich, dass mit DOM-XML der komplette <location>-Node gelöscht wird, wenn entweder</p>
<p>a) das Attribut mit dem Namen, der in $subregion gespeichert ist, im <subRegions>-Node nicht vorhanden ist<br>
b) oder dieses Attribut den Wert 0 hat.</p>
<p>Wie mache ich das möglichst einfach?</p>
<p>Liebe Grüße<br>
Sebastian</p>