"mevenden" <webforumsuser@macromedia.com> wrote in message
news:cuaglk$l0$1@forums.macromedia.com...
> Hello -
>
> Here's the function I wrote - it uses the XPath actionscript library that
can
> be downloaded at
http://www.xfactorstudio.com/ActionScript/AS2/XPath/ >
>
> import com.xfactorstudio.xml.xpath.*;
>
> function formatEmptyXMLElements(xmlIn:XML):XML {
> var tmpXML: Object = new XPathDocument(xmlIn.toString());
>
> // Select all element nodes
> var nodes:Array = tmpXML.selectNodes("//*");
>
> // Insert empty text node for elements that have no child nodes
> for (var i = 0; i < nodes.length; i++) {
> if (!nodes.hasChildNodes()) {
> nodes.appendChild(tmpXML.createTextNode(""));
> }
> }
>
> return XML(tmpXML);
> }
>
>
> -------
> As for the problem you are having, I think you have to be sure the XML is
> updated before it is actually bound to the text field. My solution to
this was
> it use an intermediary holder for the data (using a DataHolder component),
i.e.:
>
> xml_con >1> xml_dh >2> text_field
>
> The XMLConnector xml_con is not bound to the DataHolder xml_dh - #1
above is
> a function that takes the xml result from xml_con, formats the empty nodes
with
> empty text nodes, and assignes it to the data property of temp_dh. xml_dh
is
> the component that is actually bound to the text_field (#2).
>
> The purpose of all this was so I could run #1 after the binding #2 had
taken
> place, certain that the XML data had been processed first before sending
it to
> the dataholder that is bound to the text field.
>
> In your case, updating the xml connector results after the binding to the
text
> field had taken place won't I believe update the text field with your
updated
> xml (since populating the text field is done when the result event fires
from
> the connector after the xml is loaded).
>
> Anyhow, I think this is what is happening, and the solution I chose seems
to
> work for me...probably not the most efficient or elegant, but what can I
say!
> Good luck...
>
>