Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

XML issue - can it be solved with JavaScript?

5:01 pm on Sep 30, 2004 (gmt 0)

10+ Year Member

I posted my issue in the XML programming forum but I haven't received an answer. I don't do much in JavaScript but I have experience with other languages. I have an issue where I am inserting values from an XML doc using XSL/Xpath, etc and I want to avoid issues where in some cases a divide by zero occurs. I would like to be able to trap those errors and instead of dividing simply display a result of zero.

Can this be done with JavaScript? Anyone with XML/XSLT and/or JavaScript experience is welcome.


8:50 pm on Sep 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

In JS, there are 'class' properties:


How you get these numbers into Javascript via XPath is another matter.

var n=3, k=0, q;

alert("division by zero")

10:29 pm on Sep 30, 2004 (gmt 0)

10+ Year Member

I have included snippet of code to see if someone can explain how I can use a JavaScript If statement.

In psuedocode:
If XMLValueA/XMLValueB = DivideByZero
Then Display '0'
Else Display XMLValueA/XMLValueB

Here is a snippet from my xsl doc:

<td style="text-align:right;">
<xsl:value-of select="format-number(Form101_A_Value div Form101_A_Number,'$#,###,###,##0')" />



Featured Threads

Hot Threads This Week

Hot Threads This Month