You need to use the &lt; instead of the "<".  Also, if you really want the 
", <, and > strings replaced in the file with string &quot;, &lt;, &gt;, 
then you need to use &amp; instead of the &.  Here is an updated script:

<script>
  xmlfileopen = open(STAXResult,'r')
  xmlfileread = xmlfileopen.read()
  xmlfileopen.close()
  xmlfileread = xmlfileread.replace('"',"&amp;quot;")
  xmlfileread = xmlfileread.replace("&lt;","&amp;lt;")
  xmlfileread = xmlfileread.replace(">","&amp;gt;")
</script>
 
For example, if you had the following script:

<script>
  print "\" = &amp;quot;"
  print "&lt; = &amp;lt;"
  print "> = &amp;gt;"
</script>

The output would show:

20091223-08:30:03       Info    " = &quot;
20091223-08:30:03       Info    < = &lt;
20091223-08:30:03       Info    > = &gt;

Thanks, 
David 

David Bender 
STAF/STAX Development 
IBM Software Group, WPLC 
 
11501 Burnet Rd. 
Bldg. 903-5B002 
Austin, TX 78758-3400 
 
Phone (T/L): 1-512-286-5315 (363-5315) 
ITN: 23635315 
Email: bda...@us.ibm.com 
 





staf-stax user <stafstaxu...@gmail.com> 
12/23/2009 07:47 AM

To
staf-users@lists.sourceforge.net
cc

Subject
[staf-users] Can we use XML tags inside script element in stax






Hi 

I am using below mentioned piece of python code inside script element in 
STAX.xml file. 

<script>
xmlfileopen = open(STAXResult,'r')
                                                xmlfileread = 
xmlfileopen.read()
                                                xmlfileopen.close()
                                                xmlfileread = 
xmlfileread.replace('"',"&quot;")
                                                xmlfileread = 
xmlfileread.replace("<","&lt;")
                                                xmlfileread = 
xmlfileread.replace(">","&gt;")
</script>

While executing it is throwing error "The content of elements must consist 
of well formed character data or markup." 

My First question is: "Can we use XMl tags inside script element"? 
Second: How too overcome this issue?

Regard's


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and 
easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to