2 Replies Latest reply on Nov 24, 2008 11:01 AM by wkolcz

    XML HELP!

    wkolcz
      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%5B Author%5D%29%20%20AND%20%20%28%22University%20of%20Michigan%22%5BAffiliation%5D%29" 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[a].Title.xmlText,a);
      QuerySetCell(xmlqry,"link",xmlfile.item[a].link.xmlText,a);
      QuerySetCell(xmlqry,"author",xmlfile.item[a].Author.xmlText,a);
      QuerySetCell(xmlqry,"category",xmlfile.item[a].category.xmlText,a);
      }
      </cfscript>

      Here is the actual XML doc I am getting back: