0

我有一个丑陋的 druple-gardens RSS 提要进入闪存,我正在使用与此链接相同的想法。http://www.eccesignum.org/blog/accessing-views-from-flash-in-drupal-gardens将其解析为新的 xml 结构。

闪码:

            var str = item.description;
            var newString = str.split("&lt;").join("<").split("&gt;").join(">").split("&quot;`").join("\"").split("&nbsp;").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 中的名称获取元素。

4

1 回答 1

1

你有没有尝试过

var list:XMLList =yourXML.descendents('div').(attribute('class')=='field-label');
for each var (node:XML in list) {
   trace(node.text());
}

?

于 2012-06-27T23:25:06.337 回答