Jump to content

[SOLVED] More XML issues. Using DOMDocument to parse XML.


Recommended Posts

php version 4.3.9

 

I'm sending xome XML to a server who then sends XML back to me.  I use fread and get the XML sent back and I can echo my $xml variable and it has the xml.  I can then make a DOMDocument but when I use loadXML it stops and doesn't do anything after that line, including displaying the HTML I have below all my php code.  Is there something I need to configure with php for loadXML to work?  If so, how do I go about doing that?  Thanks!

 

	$xmlRequest = fsockopen($hostname, $port);		
	fputs($xmlRequest, $xmlToSend);

	while ($out = fread($xmlRequest, 1024))
	{
		$xml .= $out;
	}

	fclose($xmlRequest);

	// Parse XML data and set session variables when needed and then redirect to arSummary.php.
	$xmlDoc = new DOMDocument();

	$xmlDoc->loadXML("<?xml version=\"1.0\"?><employees><employee><name>Mike</name></employee></employees>");
	echo $xmlDoc->saveXML();

php version 4.3.9

 

I think you need PHP 5+ for DOMDocument class.

 

http://us2.php.net/dom

 

Yikes, I'm retarded.  I saw that earlier, but I was under the impression from another page I looked at made it look like 4.3.x was fine.  Anything else I can use without upgrading my php?  If not, how easy/hard is it to upgrade to the newest php 5 version?  Also, couldn't I just do a side by side install so I can test out my current php to make sure everything works?  Then migrate everything to php5 from php4?  Ugh, I wish this site was in ASP ;)

ASP = Windows...ugh. anyway...

 

You can still do DOM XML stuff in PHP 4:

 

http://us2.php.net/manual/en/ref.domxml.php

 

I assume you're on Windows and I don't know anything about developing PHP on Windows, so I can't help there. If you're on Linux, it's pretty simple from command-line or very simple from WHM/CPanel. If you're on OS X, download and install MAMP and you can toggle back and forth between PHP 4 and PHP 5.

 

 

ASP = Windows...ugh. anyway...

 

You can still do DOM XML stuff in PHP 4:

 

http://us2.php.net/manual/en/ref.domxml.php

 

I assume you're on Windows and I don't know anything about developing PHP on Windows, so I can't help there. If you're on Linux, it's pretty simple from command-line or very simple from WHM/CPanel. If you're on OS X, download and install MAMP and you can toggle back and forth between PHP 4 and PHP 5.

 

 

 

No, it's a Linux setup.  It looks like domxml is working so far.  Thanks for the help!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.