Re: Simple XML - problem with errors
| From: | Gary . | Date: | Thu, 08 Jul 2010 12:25:52 +0000 |
| Subject: | Re: Simple XML - problem with errors | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-306759@lists.php.net to get a copy of this message | ||
Richard Quadling writes:
> On 8 July 2010 08:07, Gary wrote:
>> Why am I still getting an exception when I do this:
>>
>> libxml_use_internal_errors(true);
>> $this->xml = new SimpleXMLElement($this->htmlString);
>>
>> or this
>> $this->xml = new SimpleXMLElement($this->htmlString,
>> LIBXML_NOERROR|LIBXML_NOWARNING);
>>
>> ?
>>
>> The exception says "Exception: String could not be parsed as XML".
...
> The XML needs to be "well formed" [1].
I thought so, thanks. What does libxml_use_internal_errors do then, if
it doesn't allow me to handle those problems in my own code?
> So, if it is junk, you can't
> read it using SimpleXML as the XML is not well formed.
I'm trying to just use xml_parse and so on now.
This problem really should be *so* easy. In fact I've already solved it once X(
> Try putting it through Tidy first - that is, tidy the file first.
Ha ha!
Sorry.
It's almost certainly not available. I don't want to talk about it
*cries*