【问题标题】:How to get 'count of nodes' XML, with adobe air如何使用 adobe air 获取“节点数”XML
【发布时间】:2010-11-10 09:09:58
【问题描述】:

我想问如何获取带有符号“问题”的 XML 节点数...

如果我有一些这样的 xml 数据:

 <?xml version='1.0' encoding='utf-8'?>
  <questioner>
     <question>
         <id>001</id>
         <content>soal 1</content>
          <answer>a</answer>
     </question>
     <question>
          <id>002</id>
          <content>soal 2</content>
         <answer>a</answer>
     </question>
    <question>
          <id>003</id>
          <content>soal 3</content>
          <answer>a</answer>
    </question>
    <question>
          <id>004</id>
          <content>soal 4</content>
          <answer>a</answer>
    </question>
</questioners>

【问题讨论】:

    标签: xml count air


    【解决方案1】:
    var xml:XML = ... //init xml
    var questionList:XMLList = xml.elements("question");
    questionList.length // question count
    

    这不是 AIR 特有的,Flash 到处都有 XML 功能。

    【讨论】:

    • 嗨.. alxx.. 我的意思是在空中请...你可以吗?谢谢之前
    • 我知道了,代码如下:prefsXML = stream.readUTFBytes(stream.bytesAvailable);流.close(); var domParser = 新的 DOMParser(); var XMLList = prefsXML.getElementsByTagName("问题");警报(XMLList .length);
    • 嗯,你没有提到你需要加载它。如果您的问题都在顶层,则不需要 DOMParser - XML(string) 就足够了。
    猜你喜欢
    • 1970-01-01
    • 2010-12-08
    • 1970-01-01
    • 2011-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-13
    • 1970-01-01
    相关资源
    最近更新 更多