Highlighted

Problem parsing XML data

Community Beginner ,
Feb 04, 2020

Copy link to clipboard

Copied

Hi everyone, I tried to parse a xml data but i couldnt figure it out.

I get this error:

Complex object types cannot be converted to simple values.

 

This is my code :

<cfset the_url = 'https://www.goodreads.com/author/list/210456?format=xml&key=xxxxxxxxxxxxxxxx' />

<cfhttp url="#the_url#" method="get" result="Results" timeout="999">

<cfset asd = XmlParse(Results)>

 

 

Because what is returned is more than just the content.  It also returns header information and some other things, so you have to specify "filecontent", unless you're CFDUMPing the result.

 

V/r,

 

^ _ ^

TOPICS
Getting started

Views

372

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Problem parsing XML data

Community Beginner ,
Feb 04, 2020

Copy link to clipboard

Copied

Hi everyone, I tried to parse a xml data but i couldnt figure it out.

I get this error:

Complex object types cannot be converted to simple values.

 

This is my code :

<cfset the_url = 'https://www.goodreads.com/author/list/210456?format=xml&key=xxxxxxxxxxxxxxxx' />

<cfhttp url="#the_url#" method="get" result="Results" timeout="999">

<cfset asd = XmlParse(Results)>

 

 

Because what is returned is more than just the content.  It also returns header information and some other things, so you have to specify "filecontent", unless you're CFDUMPing the result.

 

V/r,

 

^ _ ^

TOPICS
Getting started

Views

373

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 04, 2020 1
Adobe Community Professional ,
Feb 04, 2020

Copy link to clipboard

Copied

Do a dump of the results var.  Is it xml? And nothing else?

 

Some other tips:

  • In doing the dump, you should see what comes from the cfhttp, separate from any output of the page doing the dump (including cf debugging output) 
  • If the page being called in the_url is a cfml page, you want to be sure IT is not returning debug output. The xmlparse will choke on that. 
  • Another approach is to cfoutput (rather than cfdump) the results var, and then do a view>source in your browser to see what's coming back
  • Finally, I can't recall if xmlparse REQUIRES an xml "prolog" line, as the first in an xml string to parse. That would start with a line showing <?xml .. I'm writing on my phone and can't readily recall/test, but you can see the full line in the cfml docs page on xmlparse

Let us know how it goes. 

/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 04, 2020 1
Community Beginner ,
Feb 04, 2020

Copy link to clipboard

Copied

Yes is a xml file 

Content-Typeapplication/xml; charset=utf-8

 

I find the soluiton i change the variable as   'Results.filecontent'   and it worked.

But still  dont know why didn't work at the first time

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 04, 2020 0
LEGEND ,
Feb 04, 2020

Copy link to clipboard

Copied

Because what is returned is more than just the content.  It also returns header information and some other things, so you have to specify "filecontent", unless you're CFDUMPing the result.

 

V/r,

 

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 04, 2020 1