How to edit an xml node removing its declaration tag?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jordi Puigmique
    New Member
    • Jan 2011
    • 1

    How to edit an xml node removing its declaration tag?

    Hello,

    I'm using this script to change the IP settings for a server application that won't run if the xml has the version declaration tag:

    <?php

    $ip = getenv("REMOTE_ ADDR") ;

    $dom = new DOMDocument();
    $dom->formatOutput = true;

    $root = $dom->createElement( "ServerSettings ");
    $dom->appendChild($r oot);

    $IP = $dom->createElement( "IP");
    $root->appendChild($I P);

    $text = $dom->createTextNode ("$ip");
    $IP->appendChild($t ext);

    $Port = $dom->createElement( "Port");
    $root->appendChild($P ort);

    $text = $dom->createTextNode ("9875");
    $Port->appendChild($t ext);

    print $dom->saveXML($root) ;
    $dom->save("ServerSe ttings.xml")
    ?>


    it echoes properly, but still adds the declaration version line on overwriting the ServerSettings file:

    echo ex:

    <ServerSettings >
    <IP>88.8.36.147 </IP>
    <Port>34</Port>
    </ServerSettings>

    Can anyone lend me a hand? Or suggest any tutorial?
    Last edited by Jordi Puigmique; Jan 13 '11, 04:53 PM. Reason: Solved
Working...