Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
How to let iframe element know that the content being passed to it is xml

I'm working on retrieving some xhtml content at run time and displaying that within an iframe element of an html page. The problem which I'm trying to solve here is the title tag which is part of the xhtml content is being passed as a self closing tag (<title/>) and when the content is passed into iframe, it is being consumed as html which is resulting in the content not being displayed at all within iframe.

Adding a screenshot of the dom below for reference: enter image description here

Please note that when I am trying to consume the xhtml content after storing it as a separate xhtml file and retrieving it using the src tag (specifying the path to the same), the xml parsing is correctly done and I could see the text content being displayed as well. But unfortunately, the content is actually getting generated in real time in the real scenario where I'm trying to fix it so using src attribute is not an option.

I also tried accessing the contentDocument of the iframe and adding the xml content directly there but even that doesn't seem to be solving the problem.

Does somebody know of any workaround for addressing this problem?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The srcdoc attribute assumes "text/html" content type. Consider using the src attribute with a data: url like this:

<iframe src="data:application/xhtml+xml,
   <html xmlns='http://www.w3.org/1999/xhtml'>
     <head>
       <title/>
     </head>
     <body>
       <p>Hello world</p>
     </body>
   </html>">
</iframe>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!