如何计算xmldata?
我从httpservice(使用cgi)获取xml数据,并且没有设置结果格式(它仅作为对象出现),
<root>
<employee name="xxx" age="xx" gender="xxx"/>
<employee name="xxx" age="xx" gender="xxx"/>
<employee name="xxx" age="xx" gender="xxx"/>
</root>
当我尝试计算员工标签时,这种格式的xml数据,我遇到了问题,我的代码将是这样的:
var i:int=o;
for each(var obj:object in event.result.root.employee)
{
i++;
}
我得到的计数为3,但问题是,当传入数据时,它给出的计数为3(即)xml数据
<root>
<employee name="xxx" age="xx" gender="xxx"/>
<root>
实际上是我想计算员工标签的数量而不是所有子标签, 我希望你能节省我的时间 提前致谢..
i'm getting the xmldata from the httpservice (using cgi) and i have not set resultformat(it is coming as an object only),the xml data in this format
<root>
<employee name="xxx" age="xx" gender="xxx"/>
<employee name="xxx" age="xx" gender="xxx"/>
<employee name="xxx" age="xx" gender="xxx"/>
</root>
when i was tried to count the employee tag,i getting the problem, my code will like this:
var i:int=o;
for each(var obj:object in event.result.root.employee)
{
i++;
}
i getting the count as 3 but the problem it give the count as 3 when the coming data i.e)the xml data is
<root>
<employee name="xxx" age="xx" gender="xxx"/>
<root>
actually i want to count the number of employees tag not all subtag ,
i hope you may save my time
Thanks in advance..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
event.result.employee.length()
或在此处查找 .ChildNodes
http://www.republicofcode.com/tutorials/flash/xml/
或另一个
http://www.underground-flash。 com/2008/02/arraylength-vs-xmllength-in-as3.html
还有一个更专业的
http://www.thetechlabs.com /tutorials/xml/working-with-xml-e4x-and-actionscript-3/
event.result.employee.length()
or look here for .ChildNodes
http://www.republicofcode.com/tutorials/flash/xml/
or another one
http://www.underground-flash.com/2008/02/arraylength-vs-xmllength-in-as3.html
and one more professional
http://www.thetechlabs.com/tutorials/xml/working-with-xml-e4x-and-actionscript-3/