Skip to main content
Participating Frequently
February 22, 2010
Answered

id attributes being dropped by TextConverter

  • February 22, 2010
  • 1 reply
  • 619 views

I'm trying to import a well-formed bit of HTML where the span nodes have id attributes meaningful for later use in my application.  However, running the usual TextConverter.importToFlow call results in a TextFlow where the corresponding SpanElements do not have their id properties initialized.

var simple:XML = <p><span  id="hello">world</span></p>;

var textFlow:TextFlow =  TextConverter.importToFlow(simple.toXMLString(),  TextConverter.TEXT_FIELD_HTML_FORMAT);

var helloSpan:FlowElement =  textFlow.getElementByID("hello");

Contrary to expectations, the helloSpan is always null.  Poking through the textFlow children, one can see that the id value for our span is null.

This topic has been closed for replies.
Correct answer robin_briggs

I see the issues, and I agree it makes sense to do this. I've logged it as a feature request.

Thanks for reporting it!

- robin

1 reply

Adobe Employee
February 23, 2010

TEXT_FIELD_HTML_FORMAT does not support the id attribute except on <img> elements.

For that example you could use TEXT_LAYOUT_FORMAT instead of TEXT_FIELD_HTML_FORMAT.

BTW: Any reason you convert the XML to a String before calling importToFlow?  TLF will accept XML as the first parameter.  As is TLF just converts the XML to a string.

Hope that helps,

Richard

TLFanAuthor
Participating Frequently
February 23, 2010

Yeah, after reading through the current in-source documentation, I saw that id is not supported for the HTML parser.  (The toXMLString call was just some residual cargo-cultage).

My question can now be refined to "will id attributes eventually be supported?" and its corollary, "why not?"

It seems a waste to drop data without good reason.

robin_briggsCorrect answer
Adobe Employee
February 24, 2010

I see the issues, and I agree it makes sense to do this. I've logged it as a feature request.

Thanks for reporting it!

- robin