Debt Consolidation - Tea Forums & Tea Industry Forum - Wordpress Theme - Deaf Topics - Debt Consolidation

PDA

View Full Version : Coldfusion finding a word in xml file.


Hellcrasher
Oct 26th 2006, 9:44 am
I Cant resolve an issue finding word in a xml file with coldfusion.
If the xml file looks like this:



<Ark>
<Fields Apple_id="Apple2" Red_id="Red2">
<Ark>



So how can i make it to find the Apple_id and Red_id From the tag <Fields> ?
To use those later in like Insert command.

datropics
Oct 26th 2006, 9:58 am
<cffile action="read" file="#NameOfFile#" variable="XMLFile">
<cfif IsXML(XMLFile)>
Processing...
<cfflush>
<cfset XMLDoc = XMLParse(XMLFile)>
<cfset Items = XMLSearch(XMLDoc,"/Ark")>
<cfloop from="1" to="#ArrayLen(Items)#" index="I">
<cfoutput>
<br>#Items[I].Fields.XMLAttributes.Apple_ID#
<br>#Items[I].Fields.XMLAttributes.Red_ID#
</cfoutput>
</cfloop>
<cfelse>
Sorry not an XML File
</cfif>

Hellcrasher
Oct 26th 2006, 10:46 am
With it gives the value of apple_id and Red_id.
But i need to get it to work so that the apple_id and Red_id could be anything like (app3le_id and just red) and it would find those without me giving the name for it.
I have told to use findnocase and left commands for that case but i havent figured yet how.
But still thanks for response.

datropics
Oct 26th 2006, 11:40 am
What do do is, place .XMLAttributes into a structure and loop through it

Hellcrasher
Oct 26th 2006, 2:56 pm
it doesnt help , because i dont need the value.. i just need to put it finding the words apple_id , Red_id... As that i can change to anything like Redlabel_id and it can find the correct name. Without me writing that specific name in any command.

datropics
Oct 26th 2006, 2:59 pm
no worries - when you loop through XMLAttributes, you will be looping through a COLLECTION. and the KEY would be the attribute - so, once you get the Key you can change it's name (or rather assign the new name to another variable while rebuilding the XML) and continue

what do you think?

Hellcrasher
Oct 26th 2006, 3:05 pm
I didnt correctly understand your last post. What i need to do at all is to make it work so that random Xml files can be added straight to database through web when they contain same base structure.

Added you to my msn too if its ok.

datropics
Oct 26th 2006, 3:08 pm
oh wow!!! that sounds exciting

Ok - no worries - I'll think about the code tonight and get back to you - next question, how is the database setup?

Hellcrasher
Oct 26th 2006, 3:14 pm
Hmm.... damn i dont know exactly how to explain it.
I am just doing CF coding for my boss. In my comp Oracle is running on windows but in the original site it is on Linux i think.
If anything else you need to ask then contact me in msn if its ok.

datropics
Oct 26th 2006, 3:15 pm
lol - no I mean the table structure

record id, field, etc

Hellcrasher
Oct 26th 2006, 9:43 pm
Ok trying to explain again as i can to all the people.
I could use some help to use the Find and Left or mid command..
To find the word what contains the element before the = symbol.
(Xml file example in first post )

Or any other solution but with same perspectives...

Thanks..

datropics
Oct 27th 2006, 4:17 am
HellCrasher,

How did the file I sent you work out?

Hellcrasher
Oct 27th 2006, 10:37 am
Thanks alot for your help. It worked out really fine.