ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pythoncard
pythoncard
Re: [Pythoncard-users] flatfileDatabase and XML
by Shane Holloway (RuneBlade) other posts by this author
Jan 12 2003 10:21PM messages near this date
[Pythoncard-users] added homedir config support | [Pythoncard-users] Just Saying Hi *repost*
Kevin,
      A good friend of mine forward me your question, and I've learned 
many things about xml escaping rules in writing the RuneBlade tools -- 
so it's time to share!  XML attribute values were not intended to be 
multiline since that is why CDATA exists; however, putting data in 
attributes is *most* useful.  ;)  The question you've run into is 
actually a product of the datasource, and the example attribute data is 
really encoded in a C-like way, which you will have to decode explicitly.::

for key in attributes.iterkeys():
     attributes[key].replace('\\n', '\n')

It's not a function of XML, but rather the way they chose to put the 
data into XML.  However, the xml.sax.saxutils module greatly helps with 
transforming raw text into properly escaped xml CDATA and attributes.
      The really neat part is that the code from the ASPN site is 
basicly the core of the RuneBlade XML processing.  =)  This path works 
very, very well, but the xml rules do get rather /interesting/. ;)

-Shane Holloway

> > From: "Kevin Altis" <altis@[...].com>
> > In particular, right now, when I read in the XML file newlines encoded in
> > the string such as \n get quoted so they are \\n in the dictionary 
> > strings.
> > I'm not dealing with integers or floats either.
...
> > ---
> >
> > Example three record "list of dictionaries" XML file.
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <records>
> >     <rec Profile='http://biz.yahoo.com/p/a/a.html' Phone='(650) 752-5000'
> > NumberOfEmployees='41,000' Web='http://www.agilent.com' Exchange='NYSE'
> > Company='Agilent Technologies Inc.' Address='395 Page Mill Road\nPalo 
> > Alto,
> > CA 94306' Symbol='A' ></rec>
> >     <rec Profile='http://biz.yahoo.com/p/a/aa.html' Phone='(412) 
> > 553-4545'
> > NumberOfEmployees='142,000' Web='http://www.alcoa.com' Exchange='NYSE'
> > Company='Alcoa, Inc.' Address='Alcoa Corporate Center\n201 Isabella
> > Street\nPittsburgh, PA 15212' Symbol='AA' ></rec>
> >     <rec Profile='http://biz.yahoo.com/p/a/aaab.html' Phone='(561) 
> > 624-4701'
> > NumberOfEmployees='81' Web='http://www.admiraltybank.com'
> > Exchange='NasdaqNM' Company='Admiralty Bancorp, Inc.' Address='4400 PGA
> > Boulevard\nPalm Beach Gardens, FL 33410' Symbol='AAAB' ></rec>
> > </records>



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Pythoncard-users mailing list
Pythoncard-users@[...].net
https://lists.sourceforge.net/lists/listinfo/pythoncard-users

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved