How to go from a Notes form to XML for other apps?

Is it possible to create a form in Notes and have it rendered as an XML form for other apps to pull the data from?

I have created a form and changed its content type to “OTHER - text/xml”. But when accessing it on the web it doesn’t have a .xml extension so I’m not sure how I would access it from another app, or if its even possible?

If I have to resort to an agent that exports the page as xml I will, but the whole goal here is for other apps to be able to read the xml file via a url and I want that XML file to contain live data from my database as it changes. So rather than exporting a xml file at intervals and risking out of date information it just contains live data.

While I’m not a stranger to XML I’m certainly not an expert at it (especially using it in Notes) so any help or ideas would be greatly appreciated!

Subject: How to go from a Notes form to XML for other apps?

check out the ReadViewEntries url command.

Subject: RE: How to go from a Notes form to XML for other apps?

ReadviewEntries is great if you have to output XML for multiple documents at once. You just need to build the view with all the data you want and Voila!

Now if you want a single document to be sent as XML, there is no easy way. The best way is to create a form that will wrap your fields in the proper XML. There are examples of this method in the technical articles (search for XML in the technical library in the left menu).

Another possibility is to create an agent that will output the XML, but it is similar to the form thing: you will need to write the XML yourself.

I guess you can always export the document with DXL and send the resulting file… that might work too and shouldn’t be hard to do.

Subject: How to go from a Notes form to XML for other apps?

Did you change the name of the form to have a .xml extension? That works well.

Subject: RE: How to go from a Notes form to XML for other apps?

Thats does work well in a page! - I cant get XML to render in a form at all, but a page works. I just cant use fields in a page so im struggling a bit.

Subject: RE: How to go from a Notes form to XML for other apps?

Remember that you can’t use fields, but you can use computed text for @Dbcolumns and @DbLookups. That can be quite powerful.

Subject: RE: How to go from a Notes form to XML for other apps?

Yes see my previous post about how weird the ComputedText was acting in the browser (IE7). I tried it in Firefox and Netscape without a hitch (go figure?). Guess Microsoft failed my expectations yet again.

Andrew Chung was right though, even with IE7, it fails to open the XML file? Hmm, I noticed that without the ComputedText that the xml actually renders in the browser, but with the computed text it only want to download the xml file? Any ideas???

Subject: How to go from a Notes form to XML for other apps?

Versions of IE had problems interpreting XML data even if the Content-header was set properly (text/xml) unless the item being accessed had the .xml extension.

I believe this has been fixed but you may wish to use the .xml extension to be sure.

If you wish to deliver a single document you could use an agent to deliver it real-time and not export it to a file.

You can name the agent with an .xml extension if you wish.

Pass in the key to locate the document via a url parameter.

e.g. www.somesite.com/somedb.nsf/getdata.xml?OpenAgent&key=09001

Use Print statments to deliver the document.

e.g.

Print {Content-type:text/xml}

Print {<?xml version="1.0" encoding="UTF-8"?>}

Print {}

Print {}

Alternately, you can use a view and switch forms to an XML content form formatted as text/xml.

I guess you used this method. It’s acceptable if the browsers being used don’t require the .xml extension.

Subject: RE: How to go from a Notes form to XML for other apps?

WOW best answer yet thanks, Ill give it a try and post my progress. I can get it to render proper xml in a page (but not a form), Since I cant use fields in a page the information is not real time… so that wont work. I think using an agent to print out the live data into a page is a great idea I hadn’t thought of - Thanks!

CONCERNING THE EXTENTION

In doing testing I noticed if I change the name of my form to formName.xml it gets rendered that way in IE and actually displays correctly! :o)

QUESTION:

In a “Page” I tried using ComputedText (since I cant use a Field in a page) with @dbColumn look-up for the live data. Here is where it gets weird… If I preview that page in my browser without the ComputedText it renders correctly as proper xml. Now if I leave that browser window open, switch back to Designer add my ComputedText, save it, then switch back to my browser window and “F5” viola! It pulls in all my live data into a valid xml file. BUT, if I close the window and try to go back -OR- if I try to access the page with the ComputedText field already there I get a browser error? In order for it to work I have to first view the page without the computed text and then refresh the browser page after I added the computed text in designer? It feels like I am close - any ideas?

Subject: RE: How to go from a Notes form to XML for other apps?

I had no problems using a form to display the XML. I’d try to figure out why it’s not working for you rather than switch to a page.

My view form formula has:

@If(@ClientType=“Web”; “xmlDisp”;Form)

My xmlDisp form simply has

[fieldhere]

with the Content type set to Other text/xml.

If you’e getting errors make sure that there is nothing except text-based elements on your form, no tables etc.

Additionally, if the XML is misformatted this will cause an error in the browser. I found that even if I fixed it the browser would still show the error until I closed and reopened the browser.

Subject: SOLUTION - How to go from a Notes form to XML for other apps?

You said: “Additionally, if the XML is misformatted this will cause an error in the browser.”

THATS IT! I didnt realize the tabbed white space in front of the tree was so important, as soon as I did that it now opens and renders properly in all browsers, THANKS!

I took a little from each of your posts so I appreciate all the coments - learned a weath of information today, thanks guys. - Cheers!