Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml iframe not recognising 'document.getElement(s)By...'. 1

Status
Not open for further replies.

simonB2006

Programmer
Jan 11, 2006
11
EU
okay, so i'll try and keep it succinct !

I have a page, and in the page there is an iframe 'f1'.

Some code wanders off and gets one of these :
- req_catXML = new ActiveXObject("Microsoft.XMLDOM")
and loads 'stream.xlm' for my XML object, and another
- req_catXSL new ActiveXObject("Microsoft.XMLDOM")
and loads 'tree.xsl' for my XSL object.

I then call :
f1.document.open();
f1.document.write(req_catXML.transformNode(req_catXSL));
fr1.document.close();

.... obviously there's some code inbetween, but at the end of the day my iframe is beautifully populated with the contects of my XML file, formatted by the XSL file. Lovely :)

Now the problem comes !
When I try to access the iframe dom .... x = document.getElementsByTagName("Body")[0].outerHTML ... it just gives me "<Body></BODY>" !?

In other words, even though I can see the table, it does not appear to be an official part of the doc/body ? I kind of expected this.. normally i do this kind of thing with normal HTML and i append my tables to the body as children ... but I am not really used to XML/XSL ... and the XSL/XML file is a complete document generated with transformNode ... and i wouldn't know how to begin doing this with .appendChild !!

Anyone ideas ?
I can of course put source code up if required, but it's all wrapped up in my own objects etc ... and might cause more confusion !?

Many thanks in advance !

Simon




 
I cannot reproduce the behaviour you described. But one thing for sure, you need to do this.
[tt]> f1.document.write(req_catXML.transformNode(req_catXSL));[/tt]
[tt] f1.document.write(req_catXML.transformNode(req_catXSL)[red].xml[/red]);[/tt]
for ie.
 
Amendment:

My above revision is wrong. It should be read like this, separated in two lines, always for ie only.
[tt]
req_catXML.transformNode(req_catXSL);
f1.document.write(req_catXML.xml);
[/tt]
 
thanks, but i think that's making things worse ?
I've written the writing lines below with comments but basically your changes removed any xsl influence over the output.
(shortened the object names names for ease)

line [2] is the original
lines [3&4] the new ammended
(rem as appropriate)

1] f1.document.open();

2]f1.document.write(o_XML.transformNode(o_XSL));

3]o_XML.transformNode(o_XSL);
4]f1.document.write(o_XML.xml);

5]f1.document.close();

... i assume that adding the ".xml" writes JUST the xml and the xsl is filtered out ... looking at the source code of the output, this is assumption seems qualified.

Source files to be posted shortly....
 
full source files :

the working copy:


Notes:
>to see error: click on any node in the left iframe to trigger an alert showing the outerHTML of the iframe body.

File: indexXML2.htm :
html code of main body and initiates loading of xml/xsl doc

File: callXML.js :
user defined class to handle Microsoft.XMLDOM objects and return to htm page when loaded

Files: stream.xml / tree.xsl:
as described

File: css.css:
points behaviour to .htc file

File: tree.htc:
event handlers

NB:
>callXML.js has an explicit root path specified which needs changing if code relocated elsewhere.
 
Thanks for the loading up, and will take a look. I would project it to take a while...
 
tsuji,
i may have found the problem (though still no idea how to solve).
When the .htc function is called... i changed the script to :

x = document.childNodes;
alert("xo: " + x[0].outerHTML);

.. and this reveals the HTML of the .htc file, NOT the document of the iframe.

I guess this take it out of the "xml" subject of this forum/thread ... but if you have any idea of the inner workings of 'behaviors' and .htc I'd still love to know what is going on here !!!

I guess i could back out of my approach and simply put an onclick event into the code of .xsl, drop the .htc altogether.... but that's kind of defeatest and I'm more than curious to know what's going on !!


may thanks



 
First thing first, my postings above are wrong. You get the correct string. My mistake. Sorry!

If not for the new element you bring up on htc influence---that I have not looked into---, and that you make the loading thing inside a class, the mechanism of window.frames["fr1"].document.body.innerHTML would behave absolutely as expected. I think you would agree too. I don't see any problem there and I am satisfied with the behavior so observed. Thanks simon82006 for bringing the issue up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top