|
-
May 21st, 2001, 09:02 AM
#1
Thread Starter
Lively Member
Filtering a xml document using JavaScript
<script language="javascript">
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("dagskra.xml")
// Load the XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("dagskra3.xsl")
// Transform
document.write(xml.transformNode(xsl))
</script>
This script takes a xml file and display using the xsl stylesheet. In a similar code in asp you can filter the xml file before it is displayed. Can that be done in JavaScript?
-
May 21st, 2001, 09:19 AM
#2
Im confused. So is the problem that your code doesnt work? You are showing javascript code. Although you show it client side which is really kind of useless since IE 5+ already does what that code does and it wont work in netscape anyway
-
May 21st, 2001, 09:22 AM
#3
Thread Starter
Lively Member
I need to filter the xml before displaying it. I can do it in the xsl file, but I would like to do it in the htm file.
-
May 21st, 2001, 09:27 AM
#4
As far as I know, IE already filters/styles the xml BEFORE displaying if you add the stylesheet reference to the xml document.
You also did not answer my question. What is the problem with the javascript you posted?
-
May 21st, 2001, 09:30 AM
#5
Thread Starter
Lively Member
There is nothing wrong with the code. Yes IE5 does filter/style the xml document according to the xsl file. But in this case I would rather let the htm file filter the xml file instead of the xsl file.
-
May 21st, 2001, 09:36 AM
#6
-
May 21st, 2001, 09:39 AM
#7
Thread Starter
Lively Member
CAN JavaScript FILTER an xml document?
-
May 21st, 2001, 09:44 AM
#8
Ok. Yes and No. The javascript itself does not, but the MSXML parser object you set a reference to will and should output the final rendered xml/html document.
-
May 21st, 2001, 09:52 AM
#9
Thread Starter
Lively Member
Do you know the code for it?
-
May 21st, 2001, 09:53 AM
#10
the code you already posted should work. Have you tried it?
-
May 21st, 2001, 09:59 AM
#11
Thread Starter
Lively Member
It has always worked with the filter attributes in the xsl file.
But I need to add a JavaScript function that lets the MSXML parser object filter the xml with for example date='20010521'
-
May 21st, 2001, 10:12 AM
#12
Ohhhh ok now I fully understand. Hmm Im not to sure how to go about doing it in javascript. Ill see what I can come up with.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|