• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

XML HELP!

Contributor ,
Nov 24, 2008 Nov 24, 2008

Copy link to clipboard

Copied

First off, I am really light on using XML in CF. Having said that...I have to parse an XML document to use some of the information and loop it on a physician profile page. Using an example from a blog site, I am attempting (badly) to grab just the title, author, link, and category and put them into a temp recordset so I can display them on a page. Course it doesn't work.

Please help, client department is getting edgy and this is the last thing I have to do for them. THANKS!

Here is the script block:

<cfhttp url=" http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Search&db=pubmed&term=%28weadock%20WJ%5BAuthor%5D%... method="GET" />
<cfscript>
xmlfile = xmlparse(cfhttp.filecontent); //Parses the XML
/xmlsize = arraylen(xmlfile.item.xmlchildren); //item is the parent tree
xmlqry = QueryNew("title, link, author, category"); //Sets a query for output
QueryAddRow(xmlqry,xmlsize);

for(a=1;a LTE xmlsize;a=a+1) {
QuerySetCell(xmlqry,"title",xmlfile.item.Title.xmlText,a);
QuerySetCell(xmlqry,"link",xmlfile.item
.link.xmlText,a);
QuerySetCell(xmlqry,"author",xmlfile.item
.Author.xmlText,a);
QuerySetCell(xmlqry,"category",xmlfile.item
.category.xmlText,a);
}
</cfscript>

Here is the actual XML doc I am getting back:
TOPICS
Advanced techniques

Views

269

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
community guidelines
LEGEND ,
Nov 24, 2008 Nov 24, 2008

Copy link to clipboard

Copied

What version of CF are you using? Given this seems to be RSS, can you not
use <cffeed>?
http://livedocs.adobe.com/coldfusion/8/Tags_f_01.html

If not, read up on xmlSearch() and xpath.
http://livedocs.adobe.com/coldfusion/8/functions_t-z_24.html
http://www.zvon.org/xxl/XPathTutorial/General/examples.html

--
Adam

Votes

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
community guidelines
Contributor ,
Nov 24, 2008 Nov 24, 2008

Copy link to clipboard

Copied

LATEST
Nope, using BlueDisaster (I mean Dragon). No cool RSS tags for me.

Votes

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
community guidelines
Resources
Documentation