Hey Guys,

Thanks for the help... I was finally able to get it working. But now I have
a new problem. The xml pages are built dynamically and are regularly
updated. I am running into an error where if I call for an Element called
"logo" and it does not exist I will receive an error. The error message
reads as: 

"Element Logo.XMLTEXT is undefined 
in a Java object of type class coldfusion.xml.XmlNodeMap" 

The reason I get the error is because the logo element is sometimes not
there because there might not be a logo for the particular document. 

I cannot seem to figure out how to look for the Element and check if it
exists before processing and then if it does not exist don't process. 

If anyone has any ideas on how to do this I would be grateful. 

Sorry if this seems like noobi stuff, I know nothing of xml. But I'm
learning...

Thanks,
- Neal

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 18, 2003 5:34 PM
To: CF-Talk
Subject: Re: Parsing XML in ColdFusion - Help!!

Here's an example of getting the name out:

<cffile action="read" file="C:\cfusionmx\wwwroot\test.xml"
variable="XMLFileText">

<cfset myXMLDocument=XmlParse(XMLFileText)>

<cfset name = xmlSearch(myXMLDocument, "//benefitDocument/Name")>

<cfoutput>
#name[1].XmlText#
</cfoutput>

BTW, that XML file is horribly malformed.

----- Original Message -----
From: "Bailey, Neal" <[EMAIL PROTECTED]>
Date: Thursday, September 18, 2003 2:37 pm
Subject: Parsing XML in ColdFusion - Help!!

> Hello everyone... 
> 
> This is my first post to the list... 
> 
> Hopefully someone here can help me out. I'm pretty new to XML and 
> I need to
> parse an xml page so that I can extract the information out of it and
> include this information into a different page using ColdFusion MX 
> 6.1. 
> 
> I think my main problem is just understating how it all works using
> ColdFusion. I cannot fine many resources on the net that can help 
> explainhow to do this. All I need to do is extract very little 
> data out of a XML
> file. Almost like a news feed. 
> 
> Does anyone know of any useful resources that explain Parsing XML 
> usingColdFusion MX 6.1?
> 
> The file I'm trying to parse is below. The only information I need to
> extract is the Name, TagLine and Details. I then want to show this
> information on a new page. If possible can some one give me an 
> example of
> how to do this? 
> 
> Thanks,
> Neal
> 
> 
> <?xml version="1.0" encoding="utf-16" standalone="yes" ?> 
> -<!-- 
> This file represents benefit content
>  --> 
> 
> 
> - <benefitDocument>
>  <Category>Business</Category> 
>  <Name>Association 105(tm) HRA</Name> 
>  <TagLine><b>The premier tax break for your small 
> business</b></TagLine> 
>  <Icon>< FREE65.gif></Icon> 
>  <Detail><i>Over $47 million in Member savings since April 1999.
> </i><br><br> This is a call you can't afford not to make. You may 
> alreadyqualify for the Association 105 Health Reimbursement 
> Arrangement (HRA), and
> by enrolling now, the service is absolutely <b>FREE</b> to new 
> NASE Members
> in the year 2003. <b>You must call to enroll.</b><br><br> Deduct 
> 100% of
> your family health insurance premiums and other medical expenses. 
> <b>Enjoyhundreds, even thousands of dollars in real tax 
> savings!</b> A typical
> customer who pays $4,000 for health insurance and $2,000 for other 
> medicalexpenses can save between $1,800 and $2,500 in taxes. 
> <br><br> Under the new
> tax law, small-business owners will be able to deduct their health 
> insurancepremiums at 100% from a federal and state income tax 
> standpoint. However,
> the Association 105 HRA will go a step further by allowing the
> small-business owner a <b>self-employment</b> tax savings as well. In
> addition, Association 105 HRA customers will also be able to 
> deduct 100% of
> their non-insured medical expenses from <b>state, federal, and
> self-employment tax.</b><br><br> The Association 105 HRA offers you
> increased flexibility, along with the ability to carry forward unused
> benefits to the next plan year!<br><br> Do you pay for any of the 
> followingmedical-related expenses? <br><br> <ul><li>Health 
> Insurance Premiums</li>
> <li>Co-Pays</li> <li>Deductibles</li><li>Long Term Care Premiums</li>
> <li>Dental</li> <li>Vision</li> <li>Chiropractic</li> <li>Doctors 
> OfficeVisits</li> <li>Prescriptions</li></ul><br>If you answered 
> "yes," you may
> qualify for the Association 105 program.</Detail> 
>  <Call2Action /> 
>  <Teaser>Deduct 100% of your family health insurance premiums and 
> othermedical expenses</Teaser> 
>  
> <CrossSell><ul><li>show_benefit.asp?benefit=105SamplePay>SamplePay</li>
<li>show_benefit.asp?benefit=ProTaxTalk>TaxTalk </li></ul></CrossSell> 
>  <Disclaimer><font size = 1><b>NOTE: Association 105 HRA is 
> offered by
> Benefit Administration for the Self-Employed. SamplePay and 
> Association 105
> HRA are trademarks of Benefit Administration for the Self-Employed
> (BASE).</font></b></Disclaimer> 
>  </benefitDocument>
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm?link=i:4:137899
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Reply via email to