Re: HTML tags in XML
>From: Devin Asay <[EMAIL PROTECTED]> >Hi Folks, > >Is it possible to store html styled text in an xml document and then >successfully retrieve the text with html markup intact? > >I'm working on an application where I need to save styled text in an >XML document. I can successfully insert the htmlText of the styled >field into the xml document so I end up with a node that looks like >this: > > >Here are my comments. >Some of the text is colored red & >blue > > >However, when I read this node in with the revXMLNodeContents() >function the html tags are stripped out and all I get is naked text. >Here's a code snippet: > >Devin Use a pull-parser function (see below) Example : put PNLPgetElement("", "", tPullThis) into tPullThisTag for elements: function PNLPgetElement tStTag, tEdTag, stngToSch put empty into zapped put the number of chars in tStTag into dChars put offset(tStTag,stngToSch) into tNum1 put offset(tEdTag,stngToSch) into tNum2 if tNum1 < 1 then return "error" exit PNLPgetElement end if if tNum2 < 1 then return "error" exit PNLPgetElement end if put char (tNum1 + dChars) to (tNum2 - 1) of stngToSch into zapped return zapped end PNLPgetElement For an array of elements: function getPNLPelements tStartTag, tEndTag, StringToSearch put empty into tArray put 0 into tStart1 put 0 into tStart2 put 1 into tElementNum put the number of chars in tStartTag into dChars repeat put offset(tStartTag,StringToSearch,tStart1) into tNum1 put (tNum1 + tStart1) into tStart1 if tNum1 < 1 then exit repeat put offset(tEndTag,StringToSearch,tStart2) into tNum2 put (tNum2 + tStart2) into tStart2 if tNum2 < 1 then exit repeat --if tNum2 < tNum1 then exit repeat put char (tStart1 + dChars) to (tStart2 - 1) of StringToSearch into zapped put zapped into tArray[tElementNum] add 1 to tElementNum end repeat return tArray end getPNLPelements ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
Trevor- Tuesday, March 21, 2006, 11:19:29 AM, you wrote: > On Mar 21, 2006, at 11:10 AM, Mark Wieder wrote: >> Yes and no. As long as you have the data stored properly encoded then >> you should be able to decode it on the way out: >> >> set the htmlText of field "grunt" to urlDecode(xmlData) > Oh, I see what you are getting at. Yeah, that would work but > wouldn't this only work if the XML was only used in Rev. Wouldn't it > cause problems for other software that tried to read your XML document? Yes, I should think so. It would have to decode it back. I've been assuming this was just for rev data, but if you're going outside the sandbox then you'd need to stick with what the DTD says. Ken's CDATA approach would probably be the best way to deal with it in that case. -- -Mark Wieder [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
See if URLEncode() and URLDecode() will package and recover your text and/or htmltext to XML's liking...it works for me on other stuff... sqb On Mar 21, 2006, at 7:43 AM, Devin Asay wrote: Hi Folks, Is it possible to store html styled text in an xml document and then successfully retrieve the text with html markup intact? ... Here are my comments. Some of the text is colored red & blue ... Is there a way to do this? Will I have to resort to saving the RTFtext in the xml node or something like that? Hi Devin, You need to escape ", ', <, and < when entering data into an XML node. I can't remember if RevXML has any handlers for this or if you just have to do it by hand. For an example of the escape characters just do a Google search for "xml escape characters". You may want to check out Ken Ray's XML library. I haven't used it but browsing through the API, there is a stsXML_replaceEntities that looks like it would do what you want. -- Trevor DeVore Blue Mango Learning Systems - http://www.bluemangolearning.com [EMAIL PROTECTED] -- stephen barncard s a n f r a n c i s c o - - - - - - - - - - - - ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
On Mar 21, 2006, at 11:10 AM, Mark Wieder wrote: Yes and no. As long as you have the data stored properly encoded then you should be able to decode it on the way out: set the htmlText of field "grunt" to urlDecode(xmlData) Oh, I see what you are getting at. Yeah, that would work but wouldn't this only work if the XML was only used in Rev. Wouldn't it cause problems for other software that tried to read your XML document? -- Trevor DeVore Blue Mango Learning Systems - www.bluemangolearning.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
Trevor- Tuesday, March 21, 2006, 9:43:36 AM, you wrote: > On Mar 21, 2006, at 9:34 AM, Mark Wieder wrote: >> Trevor- >> >> Tuesday, March 21, 2006, 8:12:11 AM, you wrote: >> >>> You need to escape ", ', <, and < when entering data into an XML >>> node. I can't remember if RevXML has any handlers for this or if you >>> just have to do it by hand. For an example of the escape characters >>> just do a Google search for "xml escape characters". >> >> I think urlEncode() will do the trick here. > I don't think this will work in this case. For example, urlEncod > ("hi") would give you: > %3Cp%3Ehi%3C%2Fp%3E > When what you really want is: >hi
Yes and no. As long as you have the data stored properly encoded then you should be able to decode it on the way out: set the htmlText of field "grunt" to urlDecode(xmlData) -- -Mark Wieder [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
On Mar 21, 2006, at 10:30 AM, Ken Ray wrote: Actually, you can *retrieve* CDATA with revXMLNodeContents, but you can't *set* it. That's part of the reason I'm still updating my XML Library. ;-) ... Trying it with CDATA tags already around it: revPutIntoXMLNode tID,"/root/test","" put revXMLText(tID) RETURNS: This is another test]]> Thanks for the info Ken. Your XML lib looks very cool. -- Trevor DeVore Blue Mango Learning Systems - www.bluemangolearning.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
On 3/21/06 11:51 AM, "Trevor DeVore" <[EMAIL PROTECTED]> wrote: > On Mar 21, 2006, at 9:41 AM, Ken Ray wrote: > >> My XML Library handles getting and setting CDATA information for a >> node quite >> easily > > Ken, > > This is good to know. The RevXML external doesn't handle CDATA, does > it? I seem to recall that when I tested using CDATA with RevXML it > didn't work which is kind of a bummer. Actually, you can *retrieve* CDATA with revXMLNodeContents, but you can't *set* it. That's part of the reason I'm still updating my XML Library. ;-) Here's an example: Contents of Field 1: -- put fld 1 into tXML put revCreateXMLTree(tXML,true,true) into tID put revXMLNodeContents(tID,"/root/test") RETURNS: This is a test put revXMLText(tID) RETURNS: Now, we try to set the data: revPutIntoXMLNode tID,"/root/test","This is another test" put revXMLText(tID) RETURNS: This is another test Trying it with CDATA tags already around it: revPutIntoXMLNode tID,"/root/test","" put revXMLText(tID) RETURNS: This is another test]]> HTH, Ken Ray Sons of Thunder Software Web site: http://www.sonsothunder.com/ Email: [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
On Mar 21, 2006, at 9:41 AM, Ken Ray wrote: My XML Library handles getting and setting CDATA information for a node quite easily Ken, This is good to know. The RevXML external doesn't handle CDATA, does it? I seem to recall that when I tested using CDATA with RevXML it didn't work which is kind of a bummer. -- Trevor DeVore Blue Mango Learning Systems - www.bluemangolearning.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
On Mar 21, 2006, at 9:34 AM, Mark Wieder wrote: Trevor- Tuesday, March 21, 2006, 8:12:11 AM, you wrote: You need to escape ", ', <, and < when entering data into an XML node. I can't remember if RevXML has any handlers for this or if you just have to do it by hand. For an example of the escape characters just do a Google search for "xml escape characters". I think urlEncode() will do the trick here. I don't think this will work in this case. For example, urlEncod ("hi") would give you: %3Cp%3Ehi%3C%2Fp%3E When what you really want is:hi
-- Trevor DeVore Blue Mango Learning Systems - www.bluemangolearning.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
On 3/21/06 9:43 AM, "Devin Asay" <[EMAIL PROTECTED]> wrote: > Is it possible to store html styled text in an xml document and then > successfully retrieve the text with html markup intact? Yes. You need to use a CDATA node instead of a normal element node. The markup looks like this: You can put anything into a CDATA node - it's ignored by the parser. My XML Library handles getting and setting CDATA information for a node quite easily - if your XML looked like this: You could get the data with: put stsXML_GetNodeData("/root/myHTML") into tHTML and set it with stsXML_SetNodeData. By keeping it as CDATA you don't need to replace characters to get what you want... Ken Ray Sons of Thunder Software Web site: http://www.sonsothunder.com/ Email: [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
Trevor- Tuesday, March 21, 2006, 8:12:11 AM, you wrote: > You need to escape ", ', <, and < when entering data into an XML > node. I can't remember if RevXML has any handlers for this or if you > just have to do it by hand. For an example of the escape characters > just do a Google search for "xml escape characters". I think urlEncode() will do the trick here. -- -Mark Wieder [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
On Mar 21, 2006, at 9:12 AM, Trevor DeVore wrote: On Mar 21, 2006, at 7:43 AM, Devin Asay wrote: Hi Folks, Is it possible to store html styled text in an xml document and then successfully retrieve the text with html markup intact?;-) Is there a way to do this? Will I have to resort to saving the RTFtext in the xml node or something like that? Hi Devin, You need to escape ", ', <, and < when entering data into an XML node. I can't remember if RevXML has any handlers for this or if you just have to do it by hand. For an example of the escape characters just do a Google search for "xml escape characters". You may want to check out Ken Ray's XML library. I haven't used it but browsing through the API, there is a stsXML_replaceEntities that looks like it would do what you want. Thanks Trevor. I already knew that I had to escape those characters, plus '&' when writing xml. You triggered a "Duh!" moment in my brain, as it dawned on me that I'd also have to escape those other characters in my html markup. It's working now. Devin Devin Asay Humanities Technology and Research Support Center Brigham Young University ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: HTML tags in XML
On Mar 21, 2006, at 7:43 AM, Devin Asay wrote: Hi Folks, Is it possible to store html styled text in an xml document and then successfully retrieve the text with html markup intact? ... Here are my comments. Some of the text is colored red & blue ... Is there a way to do this? Will I have to resort to saving the RTFtext in the xml node or something like that? Hi Devin, You need to escape ", ', <, and < when entering data into an XML node. I can't remember if RevXML has any handlers for this or if you just have to do it by hand. For an example of the escape characters just do a Google search for "xml escape characters". You may want to check out Ken Ray's XML library. I haven't used it but browsing through the API, there is a stsXML_replaceEntities that looks like it would do what you want. -- Trevor DeVore Blue Mango Learning Systems - http://www.bluemangolearning.com [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution