/    Sign up×
Community /Pin to ProfileBookmark

PHP4 XML DOM write to document

I wrote a script which adds a element to an xml file with attributes added using the php5 DOM objects.

[code=php]
$xml_dom = new DOMDocument(); // Load DOM Object
$xml_dom -> load(“db.xml”); // Load xml databse into the object

$newsletter_log = $xml_dom -> getElementsByTagName(‘newsletter_log’)->item(0); // Asign the element to a vaible
$newElement = $xml_dom -> createElement(‘log’); // Create a new elemnt and asign to varible
$newsletter_log -> appendChild($newElement); // Apend the new element node into the parent element
$newElement -> setAttribute(‘action’, $act); // Setting new atriubts to the element
$newElement -> setAttribute(’email’, $_GET[“email”]);
$newElement -> setAttribute(‘time/date’, date(“H:i d.m.y”));
$newElement -> setAttribute(‘recommended’,$recommended);
$xml_dom -> save(“db.xml”); // Save new XML docmument

[/code]

However, I have just been notified that the script will run in a php4 environment, which I have no experience of, especially in using the old DOM extensions. I know that DOM is not always turned on with php4, how can I find this out (I have access to a phpinfo file)? Also, how can I modify the script to work with php4?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @joshlk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...