2

I have dynamic content that will grow and shrink in height that needs to be embedded into other sites that we do not host or have any control over. I was using an iframe to do this but after realizing that it is basically impossible to dynamically change the height of an iframe I started thinking about using xml. The only requirement I have is that the container MUST grow and shrink with the data being imported.

Can I use xml for this? What tag would I use to grab the data when the page loads? When the page loads, the data would need to be ready to show.

jim
  • 23
  • 1
  • 3
  • You _can_ embed XML into HTML (using a [`
    ` tag](http://reference.sitepoint.com/html/pre)), but how would you expect it to render beyond showing the raw XML text? I also don't see how XML has anything to do with the height of your "dynamic" content. What do you mean by "dynamic content," anyway?
    – Matt Ball May 04 '11 at 23:23
  • @Matt, I need the data to render as if it were html, with styling. Maybe xml isn't the way to go after all. I thought if I used xml and placed it into a div that I could control the height that way. – jim May 04 '11 at 23:25
  • While you can [associate stylesheets with XML documents](http://www.w3.org/TR/xml-stylesheet/) that really just doesn't sound like the right approach. Your problem is entirely CSS-related. You just want to be able to [change the height of an iframe](http://stackoverflow.com/questions/153152/), right? – Matt Ball May 04 '11 at 23:28
  • Yes, Matt but javascript isn't an option for me because we have no way of knowing if the sites will allow javascript tags. Basically I am providing an iframe with a link to the dynamic content, where that link winds up is anyones guess. – jim May 04 '11 at 23:30
  • I think that the best you'll be able to do is provide a little bit of JavaScript along with the iframe. An iframe is definitely the way to go when it comes to providing a component to be embedded in an arbitrary page, but that means the iframe is at the mercy of the parent page w/r/t placement, dimensions, etc. – Matt Ball May 04 '11 at 23:34
  • OK, thanks for the help and the answer, Matt. I'll see what javascript I can find to dynamically resize the iframe. – jim May 04 '11 at 23:36
  • The question I linked in a previous comment should do the trick. Here it is again: http://stackoverflow.com/questions/153152/ – Matt Ball May 04 '11 at 23:37
  • Thanks Matt. If you want to post the answer, I'll accept it for you. – jim May 04 '11 at 23:39
  • Will do. Feel free to tick another answer that comes along if it's more useful to you, though. – Matt Ball May 04 '11 at 23:41
  • Matt, one thing about the content in the link you provided... The accepted answer requires body onload event which we will not have access to. The iframe link we are providing will be embedded into forum like sites. Do you still think this link would help? – jim May 04 '11 at 23:42
  • Yes, I do. If consumers of your component (say, a forum) want to get the full benefit from it (say, dynamic resizing) then they will have to allow you some sort of JavaScript hook into their page - quid pro quo. – Matt Ball May 04 '11 at 23:44

2 Answers2

2

Copypasta'd at OP's request:

You can embed XML into HTML (using a <pre> tag), but how would you expect it to render beyond showing the raw XML text? I also don't see how XML has anything to do with the height of your "dynamic" content. What do you mean by "dynamic content," anyway?

While you can associate stylesheets with XML documents that really just doesn't sound like the right approach. Your problem is entirely CSS-related. You just want to be able to change the height of an iframe, right?

I think that the best you'll be able to do is provide a little bit of JavaScript along with the iframe. An iframe is definitely the way to go when it comes to providing a component to be embedded in an arbitrary page, but that means the iframe is at the mercy of the parent page w/r/t placement, dimensions, etc.

Community
  • 1
  • 1
Matt Ball
  • 332,322
  • 92
  • 617
  • 683
2

See section 2.4 of

http://www.w3.org/2010/html-xml/snapshot/report.html#uc04

which talks about "adding islands of more richly structured XML markup to existing HTML5 documents."

james.garriss
  • 11,468
  • 6
  • 75
  • 94
Michael Kay
  • 138,236
  • 10
  • 76
  • 143