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

XML Parse

Guest
May 15, 2009 May 15, 2009

I have a script that calls an eml page via cfhttp and would like to simply display the results. This xml structure does work

<macromedia_resources xmlns:macromedia_resources="http://www.macromedia.com/devnet/resources/macromedia_resources.dtd">

- <resource type="Article">
<title>The Macromedia XML Resource Feed will be discontinued Please switch to the RDF feed ASAP</title>
<author>Macromedia</author>
<product name="Dreamweaver" />
</resource>
- <resource type="Article">
<title>Using Image Editing Tools in Dreamweaver MX 2004</title>
<author>Patti Schulze</author>
<product name="Dreamweaver" />
<product name="Fireworks" />
</resource>
.
.
This one does not with the same script.
.
.
<bill type="s" number="2" title="S. 2: Middle Class Opportunity Act of 2009" official-title="A bill to improve the lives of middle class families and provide them with greater opportunity to achieve the American dream." last-action="2009-01-07" status="calendar" />
<bill type="s" number="3" title="S. 3: Homeowner Protection and Wall Street Accountability Act of 2009" official-title="A bill to protect homeowners and consumers by reducing foreclosures, ensuring the availability of credit for homeowners, businesses, and consumers, and reforming the financial regulatory system, and for other purposes." last-action="2009-01-07" status="calendar" />
.
.
is the attributes causing an issue?
.
.
The script looks like this:
<cfhttp url="examplewebpage">
<cfset myxmldoc = XmlParse(cfhttp.fileContent)>
</head>
<body>
<cfoutput><font color="FFFFFF">#myxmldoc#</font></cfoutput>
745
Translate
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
Community Expert ,
May 17, 2009 May 17, 2009

Probably because there is no root element, like this:

<rootElement>

<bill />

<bill />
</rootElement>

Translate
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
Guest
May 22, 2009 May 22, 2009

The doesn't work either.

<bills session="111">

<bill type="s" number="1" title="S. 1: American Recovery and Reinvestment Act of 2009" official-title="A bill to create jobs, restore economic growth, and strengthen America's middle class through measures that modernize the nation's infrastructure, enhance America's energy independence, expand educational opportunities, preserve and improve affordable health care, provide tax relief, and protect those in greatest need, and for other purposes." last-action="2009-01-07" status="calendar" />

<bill type="s" number="2" title="S. 2: Middle Class Opportunity Act of 2009" official-title="A bill to improve the lives of middle class families and provide them with greater opportunity to achieve the American dream." last-action="2009-01-07" status="calendar" />
    </bills>
This is the link

Translate
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
Community Expert ,
May 23, 2009 May 23, 2009
LATEST

Chrispilie,

The following code works for me:

<div>
<!--- convert your sample text to xml document --->
<cfxml variable="billsXml"><bills session="111">
<bill type="s" number="1" title="S. 1: American Recovery and Reinvestment Act of 2009" official-title="A bill to create jobs, restore economic growth, and strengthen America's middle class through measures that modernize the nation's infrastructure, enhance America's energy independence, expand educational opportunities, preserve and improve affordable health care, provide tax relief, and protect those in greatest need, and for other purposes." last-action="2009-01-07" status="calendar" />
<bill type="s" number="2" title="S. 2: Middle Class Opportunity Act of 2009" official-title="A bill to improve the lives of middle class families and provide them with greater opportunity to achieve the American dream." last-action="2009-01-07" status="calendar" />
</bills></cfxml>


Is billsXml an XML document? <strong><cfoutput>#isXml(billsXml)#</cfoutput></strong>


</div>

<div>
<!--- grab the web page --->
<cfhttp url="http://www.govtrack.us/data/us/111/bills.index.xml">
<!--- convert result to xml document --->
<cfxml variable="bills_xml"><cfoutput>#cfhttp.filecontent#</cfoutput></cfxml>


Is bills_xml (from govtrack.us) an XML document? <strong><cfoutput>#isXml(bills_xml)#</cfoutput></strong>
</div>

Translate
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
Participant ,
May 22, 2009 May 22, 2009

I have had problems in the past when using the "-" in file node/attribute names.  Maybe replacing it with "_" will help.

Translate
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