Dynamic XML(DOM)

View: New views
12 Messages — Rating Filter:   Alert me  

Dynamic XML(DOM)

by LSD 4Me :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

I am currenlty using a form to search for dates in a remote database. The results are returned directly in the browser in XML format. I need to setup a way to have that xml data returned dynamicaly to a page which will then give me the ability to manipulate the data returned (either display in html form or insert into a local db)

We are on CF8 and im like a deer in headlights when it comes to xml. does anybody know a good starting point? Ive researched plenty but ALL the examples require an xml file to already exist on not be generated dynamically.

Any help is appreciated! THanks!!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308743
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Parent Message unknown RE: Dynamic XML(DOM)

by Brad Wood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not sure what you mean by " results are returned directly in the
browser in XML format", but I'll ignore that for now and assume you are
calling some webservice, or cfhttping to a URL.

Have the administrators of the "remote database" provided you with an
XSD or DTD which lets you know what the XML will look like?

As long as the format of the XML (what tags and attributes there are) is
predictable, it doesn't really matter whether or not you are using XML
that was created dynamically or read from a static file-- your code will
work the same way.

ColdFusion has some VERY handy ways to deal with XML, but it may help
you to think of ColdFusion's representation of an XML object as an array
of structs.

I don't know how you are receiving the XML, but for example, it it was
in a string variable called "my_xml_string_variable", all you need to do
is:

<cfset xml_doc = xmlparse(my_xml_string_variable)>
<cfdump var="#xml_doc#">

That should at least get you started.

~Brad

-----Original Message-----
From: LSD 4Me [mailto:lsd4me@...]
Sent: Tuesday, July 08, 2008 1:03 PM
To: CF-Talk
Subject: Dynamic XML(DOM)

Hi

I am currenlty using a form to search for dates in a remote database.
The results are returned directly in the browser in XML format. I need
to setup a way to have that xml data returned dynamicaly to a page which
will then give me the ability to manipulate the data returned (either
display in html form or insert into a local db)

We are on CF8 and im like a deer in headlights when it comes to xml.
does anybody know a good starting point? Ive researched plenty but ALL
the examples require an xml file to already exist on not be generated
dynamically.

Any help is appreciated! THanks!!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308746
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Dynamic XML(DOM)

by Dominic Watson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I don't know how you are receiving the XML, but for example, it it was
> in a string variable called "my_xml_string_variable", all you need to do
> is:
>
> <cfset xml_doc = xmlparse(my_xml_string_variable)>
> <cfdump var="#xml_doc#">
>
> That should at least get you started.

Or, if you have an URL that outputs the XML, you can do:

<cfset xml_doc = xmlparse("http://www.myxmloutput.com/?foo=bar&l=45")>
<cfdump var="#xml_doc#">

ColdFusion will recognise that you are passing the parser an URL and
request the output of it as its XML input. Pretty handy really!

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;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308748
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Dynamic XML(DOM)

by LSD 4Me :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"...I don't know how you are receiving the XML, but for example, it it was
in a string variable called "my_xml_string_variable", all you need to do
is:"

This is where the confusion is. I am not sure how to parse the XML data that is returned into a variable. You are correct in that the XML is returned from a remote web service. What i am trying to do is take the results, put them into an array and then more likely than not insert it into a local DB.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308749
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Dynamic XML(DOM)

by LSD 4Me :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dominic,

The remote webservice requires data to be POSTed to it and will not accept GET. Will the xmlparse work with POST requests?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308751
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Parent Message unknown RE: Dynamic XML(DOM)

by Brad Wood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did you read my post?  I explained how to parse the xml data.  It was
the part of the code that used the xmlparse() function. (Imagine that!)
:)

When you say XML data, you're not referring to a SOAP packet are you?

Perhaps you could post your code that calls the web service so we could
get a better handle on what you are doing.

~Bard

-----Original Message-----
From: LSD 4Me [mailto:lsd4me@...]
Sent: Tuesday, July 08, 2008 1:35 PM
To: CF-Talk
Subject: Re: Dynamic XML(DOM)

"...I don't know how you are receiving the XML, but for example, it it
was
in a string variable called "my_xml_string_variable", all you need to do
is:"

This is where the confusion is. I am not sure how to parse the XML data
that is returned into a variable. You are correct in that the XML is
returned from a remote web service. What i am trying to do is take the
results, put them into an array and then more likely than not insert it
into a local DB.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308755
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Dynamic XML(DOM)

by Dominic Watson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No it won't. For that, your best bet is to use cfhttp to post the data
and store the resultant output as a variable:

<cfhttp url="http://myurl.com" method="POST">
   <cfhttpparam ...>
</cfhttp>

<cfset xmlContent = cfhttp.fileContent>

<cfset xml_doc = xmlparse(cfhttp.filecontent)>
<cfdump var="#xml_doc#">


I'm not sure of the cfhttp syntax off the top of my head (don't copy
and paste that) but that should get you started on the right path.

HTH

Dominic




2008/7/8 LSD 4Me <lsd4me@...>:
> Dominic,
>
> The remote webservice requires data to be POSTed to it and will not accept GET. Will the xmlparse work with POST requests?
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308753
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Dynamic XML(DOM)

by Dominic Watson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oops, my code shoulda looked like:

<cfhttp url="http://myurl.com" method="POST">
   <cfhttpparam ...>
</cfhttp>

<cfset xml_doc = xmlparse(cfhttp.filecontent)>
<cfdump var="#xml_doc#">

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;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308756
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Dynamic XML(DOM)

by LSD 4Me :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"...When you say XML data, you're not referring to a SOAP packet are you?"

Yes, it is a SOAP packet returned in XML format. The API that was written for the remote webservice has plenty of SOAP related requests but we are using the HTTP POST method insteatd of creating a full blown API on our side.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308758
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Dynamic XML(DOM)

by LSD 4Me :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dominic!!!!

You the man. Thats exactly what i neeeded. Now that I can have the data parsed I can manipulate it.

THANK YOU SO MUCH!!!!!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308759
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Parent Message unknown RE: Dynamic XML(DOM)

by Brad Wood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, heck-- you're making this harder than it has to be.  You don't
need a "full blown API"-- ColdFusion does all the SOAP nonsense for you!


If you are calling a SOAP web service, all you need is a couple lines of
code.  Check out:
http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applicat
ions_with_CFML/webservices4.htm

Two simple examples (copied from that page) would be:

<cfinvoke
  webservice = "http://www.xmethods.net/sd/2001/BabelFishService.wsdl"
  method = "BabelFish"
  translationmode = "en_es"
  sourcedata = "Hello world, friend"
  returnVariable = "foo">
<cfoutput>#foo#</cfoutput>

Or...

<cfscript>
  ws = CreateObject("webservice",
        "http://www.xmethods.net/sd/2001/BabelFishService.wsdl");
  xlatstring = ws.BabelFish("en_es", "Hello world, friend");
  writeoutput(xlatstring);
</cfscript>

All the SOAP stuff happens in the background and you get a regular
ColdFusion variable back.

I don't know what kind of variable your web service is returning (array,
string, complex type, ect), but looking at the WSDL will tell you that.

~Brad


-----Original Message-----
From: LSD 4Me [mailto:lsd4me@...]
Sent: Tuesday, July 08, 2008 1:53 PM
To: CF-Talk
Subject: Re: Dynamic XML(DOM)

"...When you say XML data, you're not referring to a SOAP packet are
you?"

Yes, it is a SOAP packet returned in XML format. The API that was
written for the remote webservice has plenty of SOAP related requests
but we are using the HTTP POST method insteatd of creating a full blown
API on our side.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308761
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Dynamic XML(DOM)

by LSD 4Me :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Brad,

This may work even better as this will probably allow for a better integration. I will start messing around with it now. THANKS!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308764
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4
LightInTheBox - Buy quality products at wholesale price