This content has been marked as final. Show 6 replies
The text is a child of apath if it were a property you could access it like so
With regard to the string you would use regular expression to search and replace
"bitwyse" <email@example.com> wrote in message
> Hi all,
> I am looking for some basic XML help. I have the following xml file that
> read in ( that I can control the contents ). I want to read it in, take
> user input and change the contents of the xml file with a replace.
> When the user enters a value of say 123 I want to replace XXX with 123.
> some reason I can not get this to work. I"m a total XML dork. Here is
> code I am using today without success. . .
> What happens, is the XMLNode gets another element named aPath with my
> I have tried various combinations of code to get this to work and either
> errors of null values or adding an element. Ugh. This should be simple
> I'm sure it is. I just can't figure it out. Can you help? I can change
> xml file to be what ever I want. So if that is the problem let me know.
> ?xml version="1.0" encoding="utf-8"?>
> <aPath>m:scan\XXX\reserve studyz</aPath>
> <aPath>m:scan\XXX\reserve study</aPath>
> <aPath>m:scan\XXX\2008 scanning\minutes</aPath>
> <aPath>m:scan\XXX\2008 scanning\insurance policy</aPath>
> <aPath>m:scan\XXX\2009 scanning\insurance policy</aPath>
> <aPath>m:scan\XXX\2008 scanning\budget</aPath>
> <aPath>o:\supporting docs\2008 audit information\properties\XXX</aPath>
> private function onComboBoxChange( event : CreateAuditCDEvent ) : void
> var anXMLNode : XML;
> var propertyNumber : String = event.selectedProperty;
> for each( anXMLNode in gListOfSourcePaths )
> anXMLNode.aPath = anXMLNode..aPath.toString().replace( "XXX",
> propertyNumber );
This expression: anXMLNode..aPath returns lots and lots of XML nodes.
That's probably part of your problem.
Check this out:
Also check out the text() property of the XML object.
This code should get you started:
Thank you all very much for you advice!!!
Greg, your code was spot on. Can you explain what I was doing wrong. I see your code and get what your doing, It just seems to me that mine should have worked as well. Obviously I don't have a great handle on managing XML.
Anyway you can dissect the code a bit for me and others perhaps struggling with the same issues???
Thanks again for all your help!!! You rock as always.
I'm not exactly sure, but if your gListOfSourcePaths was an XMLLIstCollection or maybe XMLList, I think it may have to do with your accessing the data as follows:
anXMLNode.aPath = anXMLNode..aPath ...
I'm no E4X and XML expert, but I usually just try to solve the problem somehow. I think I tried your syntax, and it didn't work, so I just iterated over the elements in the XMLListCollection and did the replace as in my code.
Using the RegExp may have helped as well.
Sorry I can't be of more help, but like I said, when code doesn't work, I just start to massage it in different ways, and hope it responds well. :-)
I hear you. In fact I was using an XMLListCollection as you thought. I too was trying different things but just never got to where you did.
Thanks again for the help!!!!