XMLファイル内の特定の要素を検索し、テキストノードの値を変更するコードを記述しようとしています。XMLファイルにはさまざまな名前名があります。これまで、名前を登録し、変更したい要素のテキストノードをエコーすることができました。
<?php
$xml = simplexml_load_file('getobs.xml');
$xml->registerXPathNamespace('g','http://www.opengis.net/gml');
$result = $xml->xpath('//g:beginPosition');
foreach ($result as $title) {
echo $title . "\n";
}
?>
私の質問は、SimpleXMLを使用してこの要素の値を変更するにはどうすればよいですか?nodeValueコマンドを使用しようとしましたが、機能させることができません。
これはXMLの一部です。
<sos:GetObservation xmlns:sos="http://www.opengis.net/sos/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="SOS" version="1.0.0" srsName="urn:ogc:def:crs:EPSG:4326">
<sos:offering>urn:gfz:cawa:def:offering:meteorology</sos:offering>
<sos:eventTime>
<ogc:TM_During xmlns:ogc="http://www.opengis.net/ogc" xsi:type="ogc:BinaryTemporalOpType">
<ogc:PropertyName>urn:ogc:data:time:iso8601</ogc:PropertyName>
<gml:TimePeriod xmlns:gml="http://www.opengis.net/gml">
<gml:beginPosition>2011-02-10T01:10:00.000</gml:beginPosition>
ありがとうディミトリス