Hi, everyone -
I'm connecting to an ASP/SOAP web service to pull some data in XML format with the intention of displaying some of it on a page. I think I want to use XMLReader because the dataset returned is pretty large and I only want a small part of it. I would like to stream the XML straight to my database somehow or into a file to be read if possible.
The problem I'm having is an error when trying to either write to a file (to point XMLReader at) or echoing a variable that I've defined as the result of the SOAP call. I've never used XMLReader or SOAP, just basic PHP/JS/HTML.
The XML data comes over with no problem - it prints fine when I use
echo htmlentities( $result->any );
($result is the var the XML stream is inhabiting)
but when I try to use:
$xmlFile = "result.xml";
$fh = fopen($xmlFile, 'w') or die("can't open file");
$stringData = $result;
fwrite($fh, $stringData);
or
echo substr($result, 0, 100);
I get the same error:
Object of class stdClass could not be converted to string
I think I have to convert it to a string but I'm kind of pulling out my hair at this point. Can anyone help with this error? And if there's another method or way of doing this, I'm totally open to suggestions! Bonus: a snippet for pulling certain tags from the XML stream via XMLReader? Thanks, all!