XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old June 4th, 2002, 04:36 AM
andreasdev andreasdev is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Sweden
Posts: 3 andreasdev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
data to and from a XML-document with SAX

Hello out there!

First I want to say that I am a beginner in XML with PHP. Lets make a long story short: Now I have a site using textfiles for storing data (text and all sorts of tags like form and a-tags). Now I was thinking about making a single XML document for storing all this data instead using meny files. I started to read about SAX in Beginning PHP4 and the examples worked just fine to me. Fine I thought, then this can be used to store text-data at least. But what if I would want to store form-tags, link-tags, bold-tags or other sorts of tags and text all together in one element? Okey you may say that a link-tag in one xml-element i valid if I defined that in the DTD... but I don't have time do make a DTD to work for all sorts of tags and Entitys that may be present in the xml-element. So therefore I come up whit the ide that I,before I put the data in the element, could convert < to &_lt; and " to &_amp; and so on(the underline is intended to be there). Now I could put what ever data I wanted to be in a xml-element whitout defining any DTD for that... And then when I wanted the data from the xml-document I just have to convert it back again. This would work I thought... but not. I could not use the entity-sign for < and & in the element... when I parsed the document to a page all data behind the ampersand-sign where cut of... and I don't know wy that is??! I know you proffessional programmers may think that I solved this in a not so good way... but can someone please help me to develop this system in the mos easy way? Can you give a description of how YOU would solve this problem.

Best regards

Andreas

Reply With Quote
  #2  
Old June 4th, 2002, 07:43 PM
Manuzhai Manuzhai is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 3 Manuzhai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Maybe &_lt; needs to be &_amp;lt; ?

Reply With Quote
  #3  
Old June 7th, 2002, 01:10 AM
andreasdev andreasdev is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Sweden
Posts: 3 andreasdev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy

It does not work anyway... as sone as there is a ampersand-sign (&) it gets all messed up in the php-sax-parser and I don't know wy this is happening... according to the books I have red, you can put something like &_amp; in a element if the content of the element is declared as #PCDATA. I will try to validate my document to see if there is anything else I have missed....

...to be continued

Reply With Quote
  #4  
Old June 7th, 2002, 04:03 AM
spike_hodge spike_hodge is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 1 spike_hodge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have had exactly the same problem with PERL.
I think the problem stemms from the local encoding settings, character sets and things I don't understand!
My solution was to replace every "non_word" character with:
"MySpecialString - the ascii character number - MySpecialString"
In PERL it is easy useing regular expresions (\w) matches "word charatures" and ord($char) gives the ascii number.
I then swap it a all bacck at the other end.
So the xml text that represents a space, for instance, is
"MySpecialString32MySpecialString".
I am sure PHP will have very simmilar functions.

Reply With Quote
  #5  
Old June 13th, 2002, 01:39 AM
andreasdev andreasdev is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Sweden
Posts: 3 andreasdev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes I have heard about some other people that hade the same problem to. I solved it by replace all ampersand signs with something like you described it, and then convert it back again. This work just fine... but it's not a "good loocking sulotion" I think. But does it have to be this way than it does.

Another thing that the parser did not like was the newline character "\n" or windows "\r\n" I don't know witch one of them. All I know is that as sone as I hit enter when I type in a element all data behind that would be cut off. This I solved by replace all "\n" and "\r" whit ""(nothing). Then it all will work just fine... but still not a "good loocking sulotion".

I would like to walidate my xml-document. Is there anyone that know where to get some good validator? I have tried to use XML for Java by IBM but I did not get it to work... don't really know how to install it properly....

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > data to and from a XML-document with SAX


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway