Jump to content

Packy

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Packy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I wanna edit one file on my server through it's web interface - it is configuration file for network adapter and I wanna change an IP address. I open file form my server: $open = fopen($file_path,"w"); and I save file with fwrite($open, $text);, but, it seams that it is not in the same form (or format) opened and closed. When I open original file from my ssh client, notepad do not show break lines just rectangles and all text in same line, but after edit with textarea and fwrite, it shows line by line - but format with line by line on the file looks like unrecognizable for system because linux wont read configurations from it and after reboot my network adapter is down. Thanks, Cheers.
  2. Hello, is it possible with php script to run some program from command line? For example terminal command line.
  3. I'm trying with: $dom->getElementsByTagname('SomeElement')->item(0)->nodeValue;
  4. Hello, I have an XML file, for example: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <flat-profile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SomeElement>ccccc</SomeElement> </flat-profile> and I can easily edit it with this simple code: <?php $dom = new DOMDocument; $dom->load('XML/sample.xml'); $SomeElement = $dom->getElementsByTagname('SomeElement')->item(0)->firstChild->nodeValue; echo '<br> Current value is: ' . $SomeElement . '<br>'; $dom->getElementsByTagname('SomeElement')->item(0)->firstChild->nodeValue = 'aaaaa'; $SomeElementValue = $dom->getElementsByTagname('SomeElement')->item(0)->firstChild->nodeValue; echo '<br> New value is: ' . $SomeElementValue . '<br>'; $dom->save('XML/sample.xml'); ?> This works fine, but when I, in XML file, instead of: <SomeElement>ccccc</SomeElement> have: <SomeElement/> or <SomeElement></SomeElement> It want work, it does not want to change SomeElement to a value 'aaaaa'. Is there some mistake with this code: $dom->getElementsByTagname('SomeElement')->item(0)->firstChild->nodeValue; or ????? Please help... Thanks
  5. I lose every tag... I only get values from elements. For example, XML file like this: <hotel>Paris</hotel> <room_number>5555</room_number> <beds>2</beds>, would give just: Paris55552 Thanks for reply...
  6. Hello hello, I have loaded XML file into textarea, after editing, how to save it? Going with: $sample = $HTTP_POST_VARS['XML_file_textarea']; $sample = $dom->saveXML(); $dom->save('XML/sample.xml'); does not work because I lose ane XML tag, I only have saved information between tags. Is this some validation issue where PHP delibarately strip tags or something else? Please help. Thanks... Here is complete code of page: <?php $dom = new DOMDocument; $dom->load('XML/sample.xml'); $dom->formatOutput = true; $sample = $dom->saveXML(); ?> <table border=1> <form name="XML_textarea" action="<?=$_SERVER['PHP_SELF']?>" method="post"> <tr> <td><textarea rows="30" cols="100" name="XML_file_textarea"><?php print $sample; ?></textarea></td> </tr> <tr> <td align="right"><input type="submit" name="submit" value="Submit"></td> </tr> </form> </table> <?php if ($HTTP_POST_VARS["submit"]=="Submit"){ $sample = $HTTP_POST_VARS['XML_file_textarea']; echo $sample . "<br><br><br>"; $sample = $dom->saveXML(); $dom->save('XML/sample.xml'); echo '<br>Changes saved.<br>'; } //if HTTP_POST_VARS ?>
  7. 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'); ?>
×
×
  • 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.