|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
CF8 problem with xmlsearch or malformed xml ?? access 2003 exported xmlI am having a CF8 problem reading an xml file exported from Access 2003.
My array returned from the xmlsearch function is empty. I dump the xml doument I get a fully populated structure. If I validate the xml file with xmlvalidate() I get: 1 [Error] :2:91: cvc-elt.1: Cannot find the declaration of element 'dataroot'. Here is the code, and example of the xml file. Any ideas would be appreciated. Thanks, Bob <body> <cfset xml = XMLParse("http://aplacmc/dir/some.xml") /> <cfset contacts = XMLSearch(xml,'/Media_x0020_Contacts/id') /> <cfoutput> <!--- <cfdump var="#xml#"> ---> contacts<br /> <cfdump var="#contacts#"> <!--- xml<br /><cfdump var="#xml#"> ---> arraylen:#ArrayLen(contacts)# <br> <cfset myResults=XMLValidate(xml)> Dump of myResults structure returned by XMLValidate<br> <cfdump var="#myResults#"> <cfloop index="i" from="1" to="#ArrayLen(contacts)#"> Contact: #contacts[i].xmlchildren[1].xmltext# #contacts[i].xmlchildren[2].xmltext# /><br /> </cfloop> </cfoutput> </body> </html> ======== xml file =========== <?xml version="1.0" encoding="UTF-8"?> <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" generated="2008-05-20T14:02:27"> <Media_x0020_Contacts> <ID>163</ID> <Media_x0020_Name>media name</Media_x0020_Name> <Zip>0</Zip> <Fax_x0020_Group>0</Fax_x0020_Group> <selected>0</selected> </Media_x0020_Contacts> <Media_x0020_Contacts> <ID>1</ID> <Language>English</Language> <Media_x0020_Type>Print</Media_x0020_Type> <Media_x0020_Name>Austin American Statesman</Media_x0020_Name> <Last>Zipp</Last> <First>Fred</First> <Title>Managing Editor</Title> <E-mail_x0020_address>news@...</E-mail_x0020_address> <Work_x0020_phone>512-912-2983</Work_x0020_phone> <Fax>512-999-999</Fax> <URL>#http://www.statesman.com/#</URL> <Street_x0020_address>305 S. Congress Ave.</Street_x0020_address> <City>Austin</City> <ST>TX</ST> <Zip>78704</Zip> <Fax_x0020_Group>1</Fax_x0020_Group> <selected>0</selected> </Media_x0020_Contacts> </dataroot> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/XML/message.cfm/messageid:231 Subscription: http://www.houseoffusion.com/groups/XML/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.3 |
|
|
Re: CF8 problem with xmlsearch or malformed xml ?? access 2003 exported xmlTwo things:
1. xml is case sensitive so the 'id' in the XPath expression should be 'ID'. 2. A single slash to start an XPath expression basically says 'start at the root', so '/Media_x0020_Contacts' does not match any elements (there is no Media_x0020_Contacts element in the *root* of the document. Either use a double slash to say 'match a Media_x0020_Contacts element anywhere in the document' or write the full path to the element. So: <cfset contacts = XMLSearch(xml,'//Media_x0020_Contacts/ID') /> or <cfset contacts = XMLSearch(xml,'/dataroot/Media_x0020_Contacts/ID') /> I'd ignore the validation errors ;) HTH Dominic -- Blog it up: http://fusion.dominicwatson.co.uk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/XML/message.cfm/messageid:232 Subscription: http://www.houseoffusion.com/groups/XML/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.3 |
|
|
Re: CF8 problem with xmlsearch or malformed xml ?? access 2003 exported xmlSweet. The // did it !! Thanks a bunch !!
On Wed, May 21, 2008 at 1:31 PM, Dominic Watson < watson.dominic@...> wrote: > Two things: > > 1. xml is case sensitive so the 'id' in the XPath expression should be > 'ID'. > 2. A single slash to start an XPath expression basically says 'start > at the root', so '/Media_x0020_Contacts' does not match any elements > (there is no Media_x0020_Contacts element in the *root* of the > document. Either use a double slash to say 'match a > Media_x0020_Contacts element anywhere in the document' or write the > full path to the element. So: > > <cfset contacts = XMLSearch(xml,'//Media_x0020_Contacts/ID') /> > or > <cfset contacts = XMLSearch(xml,'/dataroot/Media_x0020_Contacts/ID') /> > > I'd ignore the validation errors ;) > > HTH > > Dominic > > -- > Blog it up: http://fusion.dominicwatson.co.uk > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/XML/message.cfm/messageid:233 Subscription: http://www.houseoffusion.com/groups/XML/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.3 |
| Free embeddable forum powered by Nabble | Forum Help |