我有一个丑陋的druple-garden RSS提要进入flash,我使用与此链接相同的想法。 http://www.eccesignum.org/blog/accessing-views-from-flash-in-drupal-gardens将其解析为新的xml结构。
flash code:
var str = item.description;
var newString = str.split("<").join("<").split(">").join(">").split(""`").join("\"").split(" ").join(" ");
var description = new XML('<description>'+ newString + '</description>');
trace("myXML = "+description[0]);
我正试着看看我如何通过名字来获取每个元素。这是第一个描述节点。 描述出描述xml。
<description>
<div class="field field-name-field-hometown field-type-text field-label-above">
<div class="field-label">Home Town:</div>
<div class="field-items">
<div class="field-item even">Bemidji, Minnesota (up near where they filmed Fargo)</div>
</div>
</div>
<div class="field field-name-field-school field-type-text field-label-above">
<div class="field-label">School:</div>
<div class="field-items">
<div class="field-item even">UCONN Undergrad / Columbia MBA</div>
</div>
</div>
<div class="field field-name-field-lives field-type-text field-label-above">
<div class="field-label">Currently Live:</div>
<div class="field-items">
<div class="field-item even">Milford, CT</div>
</div>
</div>
<div class="field field-name-field-relationship field-type-text field-label-above">
<div class="field-label">relationship status:</div>
<div class="field-items">
<div class="field-item even">Married with two boys</div>
</div>
</div>
<div class="field field-name-field-tidbit field-type-text-long field-label-above">
<div class="field-label">tidbit:</div>
<div class="field-items">
<div class="field-item even">I’m an avid UCONN fan, a Green Bay Packers shareholder and I golf whenever I get the chance.</div>
</div>
</div>
<div class="field field-name-field-favorite-memory field-type-text-long field-label-above">
<div class="field-label">Favorite Memory:</div>
<div class="field-items">
<div class="field-item even">beating Worthington in the Ping Pong Tournament</div>
</div>
</div>
</description>
我试图在没有运气的情况下进入现场标签。 例如:
description.div.field-label和字段项的值
任何人都知道如何使用上面的xml中的名称来获取元素。
答案 0 :(得分:1)
你试过吗
var list:XMLList =yourXML.descendents('div').(attribute('class')=='field-label');
for each var (node:XML in list) {
trace(node.text());
}