[jQuery] Re: iframe and xml

2009-06-10 Thread Paul Mills

Hi,
I'm confused as to why you are trying to load XML into an iframe using
AJAX.
Why not just set src=atom.xml and load the feed directly into the
iframe?

Paul

On Jun 9, 9:13 pm, barton bartonphill...@gmail.com wrote:
 I have been trying to insert xml into an iframe. I can do it kinda.
 The problem is the iframe has html/html tags and if the xml has
 items that look like head tags like title etc they end up in the
 head. For example I have a atom file that looks like this:

 ?xml version=1.0 encoding=UTF-8?
 feed version=0.3 xmlns=http://purl.org/atom/ns#;
 titleGmail - Inbox for bartonphill...@gmail.com/title
 taglineNew messages in your Gmail Inbox/tagline
 fullcount4/fullcount
 link rel=alternate href=http://mail.google.com/mail; type=text/
 html /
 modified2009-06-07T22:20:48Z/modified
 entry
 titleTORNADO WARNING from 9News CustomCast/title
 summarySevere Weather Bulletin Click here to get additional current
 severe weather information This is .../summary
 link rel=alternate href=http://mail.google.com/mail?
 account_id=bartonphillips
 %40gmail.comamp;message_id=121bc3ef3abda1f1amp;view=convamp;extsrc=atom
 type=text/html /
 modified2009-06-07T19:43:10Z/modified
 issued2009-06-07T19:43:10Z/issued
 idtag:gmail.google.com,2004:1304851949303996913/id
 author
 name9News-CustomCast/name
 email9news-customc...@subs.myweather.net/email
 /author
 /entry
 .
 When I do this:
   var iframe = $(#frame)[0];
   var doc = iframe.contentDocument;
   if(!doc) doc = iframe.contentWindow.document;
   $(html, doc).load(atom.xml);

 The html head tag gets the titles rather than the
 feed version=0.3 xmlns=http://purl.org/atom/ns#; in the body?

 Is there a way to make the iframe look like an xml document instead of
 an html doc?


[jQuery] Re: iframe and xml

2009-06-10 Thread barton

Yes I have done that too. This is one of those because it's there
things. Also when I load the iframe via the src= the browser
interprets the xml (or at least Firefox does). To see the xml you have
to View|Page Source.

Also, the behavior of src=atom.xml and src=data:text/
xml;base64, (where  is the base64 encoded atom.xml) is
different. The latter does show the xml not the html rendering of it.

I am just curious why? Why can't I load the xml via load or some
other ajax function into an iframe and replace the html all
together. Is an iframe inherently an html container?

If I do $(body, doc).load(atom.xml) the xml is loaded like this:
body
feed xmlns=http://purl.org/atom/ns#; version=0.3

/feed
and that is OK.

Inquiring minds want to know:)
On Jun 10, 5:55 am, Paul Mills paul.f.mi...@gmail.com wrote:
 Hi,
 I'm confused as to why you are trying to load XML into an iframe using
 AJAX.
 Why not just set src=atom.xml and load the feed directly into the
 iframe?

 Paul

 On Jun 9, 9:13 pm, barton bartonphill...@gmail.com wrote:

  I have been trying to insert xml into an iframe. I can do it kinda.
  The problem is the iframe has html/html tags and if the xml has
  items that look like head tags like title etc they end up in the
  head. For example I have a atom file that looks like this:

  ?xml version=1.0 encoding=UTF-8?
  feed version=0.3 xmlns=http://purl.org/atom/ns#;
  titleGmail - Inbox for bartonphill...@gmail.com/title
  taglineNew messages in your Gmail Inbox/tagline
  fullcount4/fullcount
  link rel=alternate href=http://mail.google.com/mail; type=text/
  html /
  modified2009-06-07T22:20:48Z/modified
  entry
  titleTORNADO WARNING from 9News CustomCast/title
  summarySevere Weather Bulletin Click here to get additional current
  severe weather information This is .../summary
  link rel=alternate href=http://mail.google.com/mail?
  account_id=bartonphillips
  %40gmail.comamp;message_id=121bc3ef3abda1f1amp;view=convamp;extsrc=atom
  type=text/html /
  modified2009-06-07T19:43:10Z/modified
  issued2009-06-07T19:43:10Z/issued
  idtag:gmail.google.com,2004:1304851949303996913/id
  author
  name9News-CustomCast/name
  email9news-customc...@subs.myweather.net/email
  /author
  /entry
  .
  When I do this:
    var iframe = $(#frame)[0];
    var doc = iframe.contentDocument;
    if(!doc) doc = iframe.contentWindow.document;
    $(html, doc).load(atom.xml);

  The html head tag gets the titles rather than the
  feed version=0.3 xmlns=http://purl.org/atom/ns#; in the body?

  Is there a way to make the iframe look like an xml document instead of
  an html doc?