473,395 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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($root);

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

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

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

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

print $dom->saveXML($root);
$dom->save("ServerSettings.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?
Jan 12 '11 #1
0 1003

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Claudio Jolowicz | last post by:
How can XSLT stylesheets be used to edit, remove and add nodes specified by their position in the document tree? The XML document stores development tasks in a hierarchical way, i.e. tasks can...
2
by: Manoj G | last post by:
Hello, I believe there is no way to remove the default namespace declaration (For eg <DataSet xmlns="something">.... ) on an XmlNode object directly through DOM. So, what is the best way to...
6
by: SHC | last post by:
Hi all, I created an application from the Console Application (.NET) of VC++ .NET 2003, and I did "Build" the application of the attached .cpp file, volcanoes.xml and geology.dtd on my VC++ .NET...
7
by: ritchie | last post by:
Hi, I am writing for some help with editing a linked list. I would be gratful if anybody has the time to take a look at this. I am trying to edit a node by entering a date as a key. If an...
11
by: EAI | last post by:
Hi All, I have a XML of the following form <?xml version="1.0"?> <xxxx xmlns="http://xxx.xxx.com"> .... </xxxx> When I try to read xml using SelectSingleNode, I am getting exception
4
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml...
1
by: Cuperman | last post by:
I am iterating through a nodelist, and trying to edit node attributes based on conditions that are met. As soon as the first condition is met, the For Next loop finishes, even when there are...
4
by: WongMingYin | last post by:
Something I don't really understand. In http://maxnoy.com/interviews.html, Insert and Delete for linked list are defined as: int Insert(node **head, int data) and int Delete(node** head,...
6
by: Armel Asselin | last post by:
Hello, I'm searching for a simple command line tool to manipulate XML files. The idea would be commands such as that: xmanip-tool set /document/xpath/@name="value" remove //wrong-nodes add...
6
by: Olagato | last post by:
I need to transform this: <urlset xmlns="http://www.google.com/schemas/sitemap/0.84"> <url> <loc>http://localhost/index.php/index./Paths-for-the-extreme-player</ loc> </url> <url>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.