第218天:怀旧AS

星期三 阴 2~7℃

怀旧AS,续《怀旧能让人快乐》

昨天记下《怀旧能让人快乐》,从这几天对 AS 的怀旧来看,可以证实这一点。

一年没写 AS 了,上周来了个商家网点地图项目,上午遇到个问题:

<?xml version="1.0" encoding="GBK"?>
<data>
  <pics ShopNum="0"></pics>
  <pics ShopNum="3"></pics>
  <pics ShopNum="62"></pics>
</data>

_root.testNum = 3

在这种情况下,有没有什么方法可以根据 _root.testNum 与 XML 文件中的 ShopNum 对应,来得到 XML 文件中 length 的第 2 条数据?结果发现用这样一个简单的循环就可以了。

关键语句:

//…
tagNum[i] = myXML.childNodes[0].childNodes[i].attributes.ShopNum;
//…
iMax = myXML.firstChild.childNodes;
for (n=0; n<iMax.length; n++) {
  if (tagNum[n] == _root.shopNum) {
    i = n;
  }
}


The Ass and the Mule
from http://classics.mit.edu/Aesop/fab.1.1.html#479

A Muleteer set forth on a journey, driving before him an Ass and a Mule, both well laden. The Ass, as long as he traveled along the plain, carried his load with ease, but when he began to ascend the steep path of the mountain, felt his load to be more than he could bear. He entreated his companion to relieve him of a small portion, that he might carry home the rest; but the Mule paid no attention to the request. The Ass shortly afterwards fell down dead under his burden. Not knowing what else to do in so wild a region, the Muleteer placed upon the Mule the load carried by the Ass in addition to his own, and at the top of all placed the hide of the Ass, after he had skinned him. The Mule, groaning beneath his heavy burden, said to himself: "I am treated according to my deserts. If I had only been willing to assist the Ass a little in his need, I should not now be bearing, together with his burden, himself as well."

帮助别人就是帮助自己

RSS

上一篇:

下一篇:

发表评论

电子邮件地址不会被公开。 必填项已用*标注