Skip to main content
Participant
September 16, 2009
Question

Javascript element content without child elements CS3

  • September 16, 2009
  • 1 reply
  • 766 views

Hi,

i have the following problem which i hope you guys can help me with.

i have create the following xml structure in idesign

<root>

<story>

     <element1>

          <subelement>this is some content in subelement</subelement>

          this is some content in element1

     </element1>

</story>

</root>

now i want to get with javascript the content of element1.

but then i use the following code

var xmlelement = some code to get element1

xmlelement.contents or xmlelement.xmlContent.contents

i get this text returned

this is some content in subelement

this is some content in element1

and not only this text

this is some content in element1

i want only the content from element1 and not element1 and all his sub elements

This topic has been closed for replies.

1 reply

Robert at ID-Tasker
Legend
September 16, 2009

Novistorm wrote:

i want only the content from element1 and not element1 and all his sub elements

but contents of element1 contains all sub-elements

you need to get contents of element1 to variable and then get positions and length of all sub-elements and delete it from this variable ...

... or you can copy whole element1 to new TextFrame and then delete all sub-elements and then you will have only element1.contents

robin

www.adobescripts.co.uk

NovistormAuthor
Participant
September 16, 2009

ok ty, i'll search for the method to get the positions since i need the text of the other elements aswell (not at the same time though) so retrieval must be in the same order as in the xml