为什么我不能访问与出名称空间的XML节点?

编程入门 行业动态 更新时间:2024-10-25 22:35:03
本文介绍了为什么我不能访问与出名称空间的XML节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在敲我的桌子上我的头几个小时试图找出为什么我不能访问entry.author.name内容?我试图访问它每一个可能的方式,但失败了。

I've been banging my head on my desk for hours trying to figure out why I can't access the entry.author.name content? I've tried every possible way to access it but failed.

但是,当通过所有节点我环路xml.children我看到作者节点。

But when I loop through all nodes with xml.children I see the author node.

我看到作者节点是分开的原子的空间,但它不具有象其他名称空间的名称空间。

I see the author node is apart of the atom namespace but it doesn't have a namespace like the other namespaces.

public class Gdata extends Sprite { private var xml:XML = <entry xmlns="www.w3/2005/Atom" xmlns:media="search.yahoo/mrss/" xmlns:gd="schemas.google/g/2005" xmlns:yt="gdata.youtube/schemas/2007"> www.w3/2005/Atom,search.yahoo/mrss/,schemas.google/g/2005, gdata.youtube/schemas/2007 <id> gdata.youtube/feeds/api/videos/bwbZJw-C4Jk </id> <published> 2009-04-17T19:11:48.000Z </published> <updated> 2009-04-29T10:19:50.000Z </updated> <category scheme="gdata.youtube/schemas/2007/categories.cat" term="News" label="News & Politics"/> <category scheme="gdata.youtube/schemas/2007/keywords.cat" term="Garofalo"/> <category scheme="gdata.youtube/schemas/2007/keywords.cat" term="Olbermann"/> <category scheme="gdata.youtube/schemas/2007/keywords.cat" term="commentary"/> <category scheme="gdata.youtube/schemas/2007/keywords.cat" term="Janeane"/> <category scheme="gdata.youtube/schemas/2007/keywords.cat" term="news"/> <category scheme="schemas.google/g/2005#kind" term="gdata.youtube/schemas/2007#video"/> <category scheme="gdata.youtube/schemas/2007/keywords.cat" term="Keith"/> <category scheme="gdata.youtube/schemas/2007/keywords.cat" term="analysis"/> <category scheme="gdata.youtube/schemas/2007/keywords.cat" term="Party"/> <category scheme="gdata.youtube/schemas/2007/keywords.cat" term="Tea"/> <title type="text"> Janeane Garofalo Calls Tea Party Protesters Racists </title> <content type="text"> Janeane Garofalo: tinyurl/cr6rt8 EPA: tinyurl/clpyqo Veterans: tinyurl/ckbhb6 DHS: tinyurl/cctf54 DHS2: tinyurl/dahaxr John Ziegler: tinyurl/d7qbo4 Teabagging: tinyurl/ddskjo </content> <link rel="alternate" type="text/html" href="www.youtube/watch?v=bwbZJw-C4Jk"/> <link rel="gdata.youtube/schemas/2007#video.responses" type="application/atom+xml" href="gdata.youtube/feeds/api/videos/bwbZJw-C4Jk/responses"/> <link rel="gdata.youtube/schemas/2007#video.related" type="application/atom+xml" href="gdata.youtube/feeds/api/videos/bwbZJw-C4Jk/related"/> <link rel="gdata.youtube/schemas/2007#mobile" type="text/html" href="m.youtube/details?v=bwbZJw-C4Jk"/> <link rel="self" type="application/atom+xml" href="gdata.youtube/feeds/api/videos/bwbZJw-C4Jk"/> <author> <name> HowTheWorldWorks </name> <uri> gdata.youtube/feeds/api/users/howtheworldworks </uri> </author> <gd:comments> <gd:feedLink href="gdata.youtube/feeds/api/videos/bwbZJw-C4Jk/comments" countHint="2249"/> </gd:comments> <media:group> <media:category label="News & Politics" scheme="gdata.youtube/schemas/2007/categories.cat"> News </media:category> <media:content url="www.youtube/v/bwbZJw-C4Jk&f=videos&app=youtube_gdata" type="application/x-shockwave-flash" medium="video" isDefault="true" expression="full" duration="236" yt:format="5"/> <media:content url="rtsp://rtsp2.youtube/CiILENy73wIaGQmZ4IIPJ9kGbxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp" type="video/3gpp" medium="video" expression="full" duration="236" yt:format="1"/> <media:content url="rtsp://rtsp2.youtube/CiILENy73wIaGQmZ4IIPJ9kGbxMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp" type="video/3gpp" medium="video" expression="full" duration="236" yt:format="6"/> <media:description type="plain"> Janeane Garofalo: tinyurl/cr6rt8 </media:description> <media:keywords> Janeane, Garofalo, Keith, Olbermann, Tea, Party, commentary, analysis, news </media:keywords> <media:player url="www.youtube/watch?v=bwbZJw-C4Jk"/> <media:thumbnail url="i.ytimg/vi/bwbZJw-C4Jk/default.jpg" height="90" width="120" time="00:01:58"/> <media:thumbnail url="i.ytimg/vi/bwbZJw-C4Jk/1.jpg" height="90" width="120" time="00:00:59"/> <media:thumbnail url="i.ytimg/vi/bwbZJw-C4Jk/3.jpg" height="90" width="120" time="00:02:57"/> <media:thumbnail url="i.ytimg/vi/bwbZJw-C4Jk/0.jpg" height="240" width="320" time="00:01:58"/> <media:title type="plain"> Janeane Garofalo Calls Tea Party Protesters Racists </media:title> <yt:duration seconds="236"/> </media:group> <gd:rating average="3.9231105" max="5" min="1" numRaters="2289" rel="schemas.google/g/2005#overall"/> <yt:statistics favoriteCount="304" viewCount="33463"/> </entry>; namespace atom = "www.w3/2005/Atom" namespace media ="search.yahoo/mrss/"; namespace gd = "schemas.google/g/2005"; namespace yt = "gdata.youtube/schemas/2007"; public function Gdata() { var atom:Namespace = new Namespace(); trace("0",xml.children()[22]); trace("1",xml.inScopeNamespaces()); trace("2",xml..media::group); trace("3",xml..yt::statistics.@favoriteCount); trace("4",xml..yt::duration.@seconds); trace("5",xml..author ); // why????????? trace("6",xml.author ); // why????????? var x:int = 0; for each (var i in xml.children()) { if(i.localName() == 'author') { trace("author", i); } } } }

}

推荐答案

试试这个...

public function Gdata() { var atom:Namespace = new Namespace("www.w3/2005/Atom"); var media:Namespace = new Namespace("search.yahoo/mrss/"); var gd:Namespace = new Namespace("schemas.google/g/2005"); var yt:Namespace = new Namespace("gdata.youtube/schemas/2007"); default xml namespace = atom; // IMPORTANT trace("0",xml.children()[22]); trace("1",xml.inScopeNamespaces()); trace("2",xml..media::group); trace("3",xml..yt::statistics.@favoriteCount); trace("4",xml..yt::duration.@seconds); trace("5",xml..author ); // why????????? trace("6",xml.author ); // why????????? var x:int = 0; for each (var i in xml.children()) { if(i.localName() == 'author') { trace("author", i); } } }

更多推荐

为什么我不能访问与出名称空间的XML节点?

本文发布于:2023-11-16 21:15:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1607488.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:节点   名称   空间   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!