470,833 Members | 1,952 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

hello

Hello
I have a problem with convert document fragment to string in mozilla

var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xslDocument);
var myFragment = xsltProcessor.transformToFragment(xmlDocument, document);

Thanks
Jul 23 '05 #1
4 1815


Pampam wrote:
I have a problem with convert document fragment to string in mozilla

var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xslDocument);
var myFragment = xsltProcessor.transformToFragment(xmlDocument, document);


A fragment is a node, why do you need a string and how do you expect the
string to look, do you want the text content in the fragment node, do
you want to serialize the markup?
If you are converting some IE/MSXML code to Mozilla and are used to
htmlElement.innerHTML = xmlDocument.transformNode(xslDocument)
with IE then for Mozilla you need to learn to use DOM methods e.g.
while (htmlElement.hasChildNodes()) {
htmlElement.removeChild(htmlElement.lastChild);
}
htmlElement.appendChild(myFragment);
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
> A fragment is a node, why do you need a string and how do you expect the
string to look, do you want the text content in the fragment node, do
you want to serialize the markup?
If you are converting some IE/MSXML code to Mozilla and are used to
htmlElement.innerHTML = xmlDocument.transformNode(xslDocument)
with IE then for Mozilla you need to learn to use DOM methods e.g.
while (htmlElement.hasChildNodes()) {
htmlElement.removeChild(htmlElement.lastChild);
}
htmlElement.appendChild(myFragment);


I know in IE is ok, xmlDocument.transformNode(xslDocument) returning string.
I want to show my transform result in a window.alert(), therefore I must
convert this to string.

Thanks
Jul 23 '05 #3


Pampam wrote:
A fragment is a node, why do you need a string and how do you expect the
string to look, do you want the text content in the fragment node, do
you want to serialize the markup?
I want to show my transform result in a window.alert(), therefore I must
convert this to string.


What kind of string do you want, the serialized markup, the text
content? It is not clear what kind of string value you are looking for.

If you want the serialized HTML markup then do
var div = document.createElement('div');
div.appendChild(myFragment);
alert(div.innerHTML);

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4
> If you want the serialized HTML markup then do
var div = document.createElement('div');
div.appendChild(myFragment);
alert(div.innerHTML);

THANKS !!!! its it :)
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

24 posts views Thread by Andy Sutorius | last post: by
2 posts views Thread by bissatch | last post: by
4 posts views Thread by arnuld | last post: by
1 post views Thread by James T. Dennis | last post: by
Nepomuk
reply views Thread by Nepomuk | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.