[Flashcoders] XPath, apostrophe, XPath's escape chars?
Hey everyone, I need to search an XML via a string that may contain apostrophes. ex.: var sDesc:String = XPath.selectNodes(_xml, //[EMAIL PROTECTED]' + sReleasedLabel + ']/@writeup)[0]; Is there a way to escape the apostrophe? The problem is that the sReleasedLabel, which contains Chinese New Year '06, is thought to end at ... Year because of the apostrophe. I've tried / and \ as escape chars but they don't work. Got any suggestions? Thanks! -- Ramon Miguel M. Tayag Managing Director Quirkworks ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] XPath, apostrophe, XPath's escape chars?
Ramon, I need to search an XML via a string that may contain apostrophes. ex.: var sDesc:String = XPath.selectNodes(_xml, //[EMAIL PROTECTED]' + sReleasedLabel + ']/@writeup)[0]; Is there a way to escape the apostrophe? The problem is that the sReleasedLabel, which contains Chinese New Year '06, is thought to end at ... Year because of the apostrophe. I've tried / and \ as escape chars but they don't work. You should be able to use double quotes surrounding the expression you are looking for... XPath.selectNodes(_xml, //[EMAIL PROTECTED] + sReleasedLabel + \]/ @writeup)[0]; This is something that wouldn't work in an xpath statement in an XML file, but you should be able to get away with it in ActionScript depending on whether the xpath library you are using supports this notation. Other than that there is no solution to your problem. Better to encode your attribute values so that they contain apos; instead of apostrophe characters. Cheers, Steve -- Steve Webster Head of Development Featurecreep Ltd. http://www.featurecreep.com 14 Orchard Street, Bristol, BS1 5EH 0117 905 5047 ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] XPath, apostrophe, XPath's escape chars?
Steve, Thanks, I'll try using quotes. I do used apos; all the time, but it becomes an apostrophe somewhere there when Flash loads the XML doc. Thanks! On 4/10/06, Steve Webster [EMAIL PROTECTED] wrote: Ramon, I need to search an XML via a string that may contain apostrophes. ex.: var sDesc:String = XPath.selectNodes(_xml, //[EMAIL PROTECTED]' + sReleasedLabel + ']/@writeup)[0]; Is there a way to escape the apostrophe? The problem is that the sReleasedLabel, which contains Chinese New Year '06, is thought to end at ... Year because of the apostrophe. I've tried / and \ as escape chars but they don't work. You should be able to use double quotes surrounding the expression you are looking for... XPath.selectNodes(_xml, //[EMAIL PROTECTED] + sReleasedLabel + \]/ @writeup)[0]; This is something that wouldn't work in an xpath statement in an XML file, but you should be able to get away with it in ActionScript depending on whether the xpath library you are using supports this notation. Other than that there is no solution to your problem. Better to encode your attribute values so that they contain apos; instead of apostrophe characters. Cheers, Steve -- Steve Webster Head of Development Featurecreep Ltd. http://www.featurecreep.com 14 Orchard Street, Bristol, BS1 5EH 0117 905 5047 ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- Ramon Miguel M. Tayag Managing Director Quirkworks ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com