Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1244
  • Last Modified:

domdocument expects parameter 2 to be long, string given

Warning: domdocument() expects parameter 2 to be long, string given in browser-stats.php on line 10

Fatal error: Call to undefined function: load() in browser-stats.php on line 11

PHP Version 4.4.9, domxml enabled
$doc = new DOMDocument('1.0', 'iso-8859-1');
$doc->load('browser-stats.xml');

Open in new window

0
ellandrd
Asked:
ellandrd
  • 5
  • 2
1 Solution
 
cr4ck3rj4ckCommented:
Seen this problem around before.

The problem lies in your php.ini file which most likely loads the php_domxml.dll. PHP5 comes default with the DOM extention enabled. php_domxml is for PHP4 and should be commented.
0
 
ellandrdAuthor Commented:
im not using PHP5.  im using PHP4.4.9.  been searching for solution all morning and still nothing will work regardless of what i try
0
 
TobiasCommented:
Hi !

This function need php 5.

You can use DOM XML : http://www.php.net/domxml

Best Regards
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ellandrdAuthor Commented:
arent i using dom xml??
0
 
TobiasCommented:
Hi !

Sorry, forget that I have say.
0
 
ellandrdAuthor Commented:
ok can somebody point me to some XML examples too:

create new node
update attribute value

in PHP5?
0
 
ellandrdAuthor Commented:
ok i have been trying to get mu page working in PHP5 using SimpleXML.

however i cant seem to add a new node.

my XML file looks like this:

<?xml version="1.0"?>
<browsers>
      <browser name="Firefox" version="3.0" platform="WinXP" users="46"/>
</browsers>

I want to add a new browser node so my XML file would look like this:

<?xml version="1.0"?>
<browsers>      
      <browser name="Firefox" version="3.0" platform="WinXP" users="46"/>
        <browser name="Opera" version="9.2" platform="WinXP" users="1"/>
</browsers>
<?php
$xmlobj = simplexml_load_file('browser-stats.xml');
 
$browser = $xmlobj->addChild('browser');
$browser->addAttribute('name','Opera');
 
$xmlobj->asXML('browser-stats.xml');
?>

Open in new window

0
 
ellandrdAuthor Commented:
ok i got it working after some struggle but who gets it right first time??


<?php
$browser = array();
$browser = get_browser(null, true);
 
$name = $browser['browser'];
$version = $browser['version'];
$platform = $browser['platform'];
$users = 1;
 
$xmlobj = simplexml_load_file('browser-stats.xml');
 
$query = '/browsers/browser[@name="'.$name.'"][@version="'.$version.'"][@platform="'.$platform.'"]';
 
$entries = $xmlobj->xpath($query);
 
if(count($entries) == 1)
{
	$entries[0]->attributes()->users = $entries[0]->attributes()->users + 1;
}
else
{
	$browserobj = $xmlobj->addChild('browser');
	$browserobj->addAttribute('name',$name);
	$browserobj->addAttribute('version',$version);
	$browserobj->addAttribute('platform',$platform);
	$browserobj->addAttribute('users',$users);
}
 
$xmlobj->asXML('browser-stats.xml');
?>

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now