Jump to content

Change element in XML file


Packy

Recommended Posts

Simple problem, hope simple solution.

 

How to edit element in XML file?

 

Here what I have been trying...

 

<?php

$dom = new DOMDocument;

$dom->load('XML/sample.xml');

 

if ($dom->getElementsByTagname('Static_IP')) {

$Static_IP = $dom->getElementsByTagname('Static_IP');

$Static_IP_value = $Static_IP->item(0)->firstChild->nodeValue;

 

print "IP address: $Static_IP_value";

 

$IPaddress =10.10.1.1;

 

????????????

How to add this variable into te element name Static_IP

????????????

 

 

$dom->formatOutput = true;

$sample = $dom->saveXML();

$dom->save('XML/sample.xml');

 

?>

Link to comment
https://forums.phpfreaks.com/topic/80615-change-element-in-xml-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.