Forums / Setup & design / Fetching an xml from an URL

Fetching an xml from an URL

Author Message

Jorge estévez

Wednesday 07 April 2010 5:18:44 am

Hello,

 

I have this javascript that loads an xml from a file

 

As loading from a file is a rather a bad solution to maintain in a changing ez project I have made the arrangements to generate the xml when a viewmode is used ..content/view/xml, so when a node of certain class-type is accessed by this view-mode I get my xml in the correct format (as the code of the page).

 

Now the problem, the url that leads to the page with the xml is something like http://MYSITE/uh/index.php/esl/content/view/xml/229 . The main difference is that when loaded from a file the name of the file is xxx.xml but in this case I need to access from the javascript the content (code) of the page …

 

I need to fetch the XML content from an url with the custom-viewmode of the node,

How can I do this?

 

thanks

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Gaetano Giunta

Thursday 08 April 2010 12:35:01 am

Sorry, could you rephrase what your problem is? It is not very clear... Js can load xml files via http requests, regardless of their filename

As for your setup:

- you probably need to alter the content-type header sent along with the xml for things to work properly: set up a new layout and use an url like /layout/set/xml/node/view/xml/229 (see layout/set/print as an example)

- if /layout/set/xml/node/view/xml/229 is a bit ugly, you can set up a wildcard rewrite rule to have eg. /xmlview/229 as url

- if you want to omit the node id and use the node name instead, you can set up a separate siteaccess, with an 'xml' design as main design (where the xml template is the full one), and where the content-type header is sent via the parameters in site.ini; Thius the url could become http://mysite/index.php/xml/path/to/the/node.xml (just name the node with a trailing xml)

Principal Consultant International Business
Member of the Community Project Board