Martin Honnen <ma*******@yahoo.de> wrote:
Curious wrote:
I have an XML file which I'm rendering using XSLT in IE6. I want to
transform the original XML into a Javascript object.
Example:
foo.xml has
<?xml-stylesheet type="text/xsl" href="bar.xslt" ?>
<somedata>
<firstobject>further nested stuff
</firstobject>
</somedata>
Bar.xslt encodes
...
<script language="JavaScript" type="text/javascript">
var mystuff = <some function that allows the following>
mystuff.firstobject....
</script>
Anyone have such a function?
Maybe
document.XMLDocument
is what you are looking for, it is a property of the document object
which points to original XML as a DOM document object
I believe what he's looking for is a XSLT that would generate (for the
XML above) this:
var mystuff = {
firstobject: "further nested stuff"
}
Or if the XML was, for example
<somedata>
<a>
<b c="1">
<d />
</b>
<b />
<e>text</e>
</a>
</somedata>
then
var mystuff = {
a: {
b: [
{ c: 1, d: null },
null
],
e: "text"
}
}
Does that sum up your question?
I have a function that takes a XML DOM node and generates a JScript
object as I described above by walking the DOM, not by applying XSLT.
I'm virtually certain I can't just release it to the public domain...
Regards,
Steve