This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

stripping unwanted chars and creating valid xml file

Old posts that have not been replied to for several years.
Locked
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

stripping unwanted chars and creating valid xml file

Post by Ofloo »

Code: Select all

  proc xTags {arg} {
    foreach {x} [split $arg {}] {
      if {[regexp {^[\x80-\xff\x3c\x3e\x26]$} $x]} {
        append r "&#[scan $x %c];"
      } elseif {[regexp {[^\x01-\x19$]} $x]} {
      	append r $x
      }
    }
    return $r
  }
anyone know how this can be done faster ??

takes 10 seconds to parse the mysql db into a xml file.. thats a bit long ..
XplaiN but think of me as stupid
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

I fail to see how your code snippet is mysql- or XML-related

what you do is escaping some characters with HTML codes in a manner that hardly could be improved upon - but then again, this shouldn't be neccesary - the bottleneck is usually in parsing (large) XML files, not in generating it
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

well every char that is outside that range will make the xml file unreadable for a browser .. so all them browsers are wrong? on the otherhand i know youre right cause .. xml is more then just html its a form of db.. and it shouldn't matter what chars i use.. and they sure as hell shouldn't be html like.. if i understood right.. what xml represents..

Code: Select all

  proc xTags {arg} {
    foreach {x} [split $arg {}] {
      if {[regexp {^[\x80-\xff\x3c\x3e\x26]$} $x]} {
        append r "&#[scan $x %c];"
      } elseif {![string is control $x]} {
      	append r $x
      }
    }
    return $r
  }


thats 2 seconds faster..
XplaiN but think of me as stupid
Locked