Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Getting all the text values in an XML node

LEGEND ,
Jan 22, 2013 Jan 22, 2013

Suppose I've got an XMLList that I'm working my way through and I want to quickly and easily get all the "text" from the node. In other works strip out all the <xmtag> mark up and possible attributes and just leave the content.

Is there an easy/fast way to do that?

<myNode>

     <title>The title of an event here</title>

     <presenter>Name and title of presenter here</presenter>

     <date startTime="Somedate" />

      <desc><![CDATA[Some text in here. It <b>might</b> have html or links or some such.]]></desc>

     <resources>

          <res>A list of some resources, downloads, etc.</res>

           <res>Some other site or some such</res>

     </resources>

</myNode>

TOPICS
ActionScript
870
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 22, 2013 Jan 22, 2013

if xml is your XML instance, after loading is complete:

trace(xml.descedants("*").text());

Translate
Community Expert ,
Jan 22, 2013 Jan 22, 2013

if xml is your XML instance, after loading is complete:

trace(xml.descedants("*").text());

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 22, 2013 Jan 22, 2013

Awesome. I'm going to give that at try and see if I can speed up my indexing code. A big chunk of it has been removing all the "junk" before stemming the words.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2013 Jan 22, 2013

i'm not sure how fast that is but it's sure easy to code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 22, 2013 Jan 22, 2013

Yeah. My indexing is taking longer than I would like. So far I've been using RegEx and some other tricks. Just wanted to see if there was another way to approach it. Maybe it will be faster, maybe it won't, but I won't know until I try!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2013 Jan 22, 2013
LATEST

regex is slow.  it's faster to use the flash string/array methods.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines