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> Code (markup): 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.
<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.Fields.XMLAttributes.Apple_ID# <br>#Items.Fields.XMLAttributes.Red_ID# </cfoutput> </cfloop> <cfelse> Sorry not an XML File </cfif>
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.
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.
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?
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.
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?
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.
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..