Skip to content

XML issue and solution #295

@nonwip

Description

@nonwip

I started a project yesterday that depends on your CURL class and I noticed that there's a problem with response. Before your class, I used another one that always returned "string" as response, no matter what Content-Type it actually is.

So after converting to your class, I noticed that my project is failing everywhere I used json_decode() or new SimpleXMLElement, as it returns the properly formatted object already, except that it fails for XML in some situations.

I tracked down your method parseResponse and noticed that simplexml_load_string is not good for every XML situation where it may contain nested XML objects (if I may call it that way).

So I just made slight modification from this:
$xml_obj = @simplexml_load_string($response);

Response before:
screen shot 2016-01-29 at 20 20 49

To this:
$xml_obj = @simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);

Response after:
screen shot 2016-01-29 at 20 21 19

And now it works perfectly... Just a tip, hopefully it will get updated officially after you read this.
I am not familiar with contributions - where I make changes and you add to the master branch, so I'll try to avoid that for now and just open the issue as it's simpler this way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions