如何将xml中的文本加载到html [英] how to load text in xml to html
问题描述
实际上我已经从xml检索数据到html并放入选框滚动我已编写代码但不能正常工作请按照以下代码
这是xml
< company>
< staff>
< month> 12
< date> 31
< message> 如果你愿意相信,你很容易被欺骗
< staff>
< month> 12
< date> 30
< message>在你得分之前,你必须首先有一个目标。
< staff>
< month> 12
< date> 29
< message>在你得分之前,你必须首先有一个目标。
< staff>
< month> 12
< date> 28
< message>如果你愿意相信,你很容易欺骗
< staff>
< month> 12
< date> 27
< message>明天的所有鲜花都在昨天的种子中
< staff>
< month> 12
< date> 26
< message>在你得分之前,你必须首先有一个目标。
< staff>
< month> 12
< date> 25
< message>如果你想得到尊重,你必须尊重自己。
这是javascript我写的但没有工作
for(i = 0; i
actually i have retrieve data from xml to html and put in marquee scrolling i have written code but not working please follow below code
this is xml
<company>
<staff>
<month>12
<date>31
<message>"If you are ready to believe, you are easy to deceive"
<staff>
<month>12
<date>30
<message>"Before you can score you must first have a goal."
<staff>
<month>12
<date>29
<message>"Before you can score you must first have a goal."
<staff>
<month>12
<date>28
<message>"If you are ready to believe, you are easy to deceive"
<staff>
<month>12
<date>27
<message>"All the flowers of tomorrow are in the seeds of yesterday"
<staff>
<month>12
<date>26
<message>"Before you can score you must first have a goal."
<staff>
<month>12
<date>25
<message>"If you want to be respected, you must respect yourself."
this is javascript i have written but not working
for (i=0;i
推荐答案
你误解了for语句的格式。使用你的代码,JavaScript词法解析会给你例如
You misunderstood the format of the for statement. With your code, JavaScript lexical parsing will give you the exception like "
SyntaxError:
missing ; after for-loop condition
(实际错误对象取决于JavaScript实现。)
如果你在第一个';'之后删除i,它将是
(Actual error object depends on JavaScript implementation.)
If you remove "i" after first ';', it will be
SyntaxError:
expected expression, got keyword 'if'
但问题是:即使处理异常,也看不到这些异常,因为语法如果你只是把你的代码放在你的脚本中就不会发现错误;脚本会无声地失败。
如果你问我如何知道这些错误,我会回答后来;我正在使用我的特殊技术。
问题的本质是:你不能在for循环中使用if,你需要自己使用一些布尔条件:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for 。
我希望这篇文章能说清楚。
现在,我如何公开那些 SyntaxError
对象?这是我在我的文章 JavaScript Calculator 中找到并发布在CodeProject上的JavaScript技术, 5.处理词汇错误。阅读它,你会理解它。
But the trouble is: you cannot see these exceptions, even if you handle exceptions, because the syntax errors are not caught if you just put your code in your script; the script fails silently.
If you ask me how I know about those errors, I'll answer later; I'm using my special technique.
The essence of the problem is this: you cannot use "if" in the for loop, you need to use some Boolean condition itself:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for.
I hope this article will make it clear for you.
Now, how I expose those SyntaxError
objects? This is the JavaScript technique I found and published on CodeProject in my article JavaScript Calculator, the section "5. Handling Lexical Errors". Read it and you will understand it.
这篇关于如何将xml中的文本加载到html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!