Link to home
Start Free TrialLog in
Avatar of questhaven
questhaven

asked on

Coldfusion and XML - need assistance reading XML values - am desperate!

I'm afraid I have virtually no experience working with XML & Coldfusion, so any advice that anyone can provide would be great.  I am trying to grab a web page and get the certain values into a database.  The web page I am calling with <cfhttp> is a php file that returns contents as XML.

i.e.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE workspace PUBLIC "-//workname//DTD workspace 1.0" "http://localhost:8080/workspace/p.dtd">
<working type="d">
          <off><u>132915</u></off>
</working>
<working type="d">
    <on><u>132915</u></on>
</working >
<working type="d">
          <off><u>13112</u></off>
</working>

I am totally baffled as to how to accomplish getting the values for which numbers come across as <off></off> and which come across as <on></on> read out of the xml and into a usuable format.  If you need more information or I am not clear on this, please just let me know!

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Marco_van_den_Oever
Marco_van_den_Oever

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of questhaven
questhaven

ASKER

Thanks for your help Marco!  In the end I decided to write a parser to grab the data I needed - I  figured that I am not dealing with a huge amount of data anyway, so it just made more sense.  Here is the parser in case anyone else runs into this and wants to see an alternative:

<cfscript>
      onList = "";
      if (findNoCase("<on>", xmlString))
      {
            onList = removeChars(xmlString, 1, findNoCase("<on>", xmlString) + 6);
            onList = replaceNoCase(removeChars(onList, findNoCase("</on>", onList) - 4, len(onList)), "</u><u>", ",", "all");
      }
      
      offList = "";
      if (findNoCase("<off>", xmlString))
      {
            offList = removeChars(xmlString, 1, findNoCase("<off>", xmlString) + 7);
            offList = replaceNoCase(removeChars(offList, findNoCase("</off>", offList) - 5, len(offList)), "</u><u>", ",", "all");
      }
</cfscript>
Hi there:) No problem, great to help and thanks for the example code, it's in my snippets folder now :)