开发者

Pretty printing does not seem to be working properly

These are a few lines of code I have written in my fla.

var phoneBookXML:XML = <phonebook><Name>Bobby Francis Joseph</Name><Age>25</Age><Sex>M</Sex></phonebook>;

phoneBookXML.prettyPrinting = false;
trace(phoneBookXML.toXMLString());

trace("*********************");

phoneBookXML.prettyPrinting = true;
trace(phoneBookXML.toXMLString());

The output from the output window is

<phonebook>
  <Name>Bobby Francis Joseph</Name>
  <Age>25</Age>
  <Sex>M</Sex>
  <prettyPrinting>false</prettyPrinting>
  </phonebook>
 *********************
<phonebook>
 <Name>Bobby Francis Joseph</Name>
 <Age>25</Age>
 <Sex>M</Sex>
 <prettyPrinting>true</prettyPrinting>
</phonebook>

Now if you see the prettyPrinting property does not seem to be working since both the ouput are same. My understanding is that content should render 开发者_如何学JAVAwithout indentation or any spacing. Any idea why this is happening so.


prettyPrinting is a static property. What you're actually doing is adding a property called prettyPrinting to the phonebook XML object.

Change your code to:

XML.prettyPrinting = false;
trace(phoneBookXML.toXMLString());

And it'll work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜