Reputation: 533
I am having a hard time to get the xml content of my iframe on IE9. On other browser, it is working well but the way it rendered on IE9 is my problem.
My iframe and it's content rendered on IE9:
<iframe name="myiframe' id="myiframe">
<Namespace xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Nodes>
<node>
<node>
<Links>
........
The code that I use to get the content:
var iframe: HTMLIFrameElement = <HTMLIFrameElement>document.getElementById('myiframe');
var xml = iframe.contentWindow.document.firstChild.textContent;
When I tried to alert
the xml
, it is displaying only the content of the node, not including the node title, even the <
and >
.
I need the xml string value. Any thoughts?
Upvotes: 0
Views: 279
Reputation: 74738
Actually that is invalid as per your markup, you have put the nodes between the opening/closing of iframe
and that only executes if any browser doesn't support iframes. An example of iframe @MDN
Also getting text content from iframe
is also actually depends on Same origin policy.
.textContent
is doing correct thing to get the text of the element you are targeting. If you want to get the html/Node
of the element you are targeting then you should use outerHTML
:
var xml = iframe.contentWindow.document.firstChild.outerHTML;
Upvotes: 1