Results 1 to 1 of 1
Apr 18, 2005, 01:20 #1
- Join Date
- Oct 2004
- 0 Post(s)
- 0 Thread(s)
process xml with nested html elements
i'm currenty working on a system (php5), which handles xml data and generates forms. the xml-specification alllows to use html elements in particular xml-elements. the problem is, that all has the same namespace, so i can't differ with that.
i have to realize two different tasks: view-mode (forms are generated out of the xml) and edit-mode (user has the abilty to change the xml). in the first task, i use a sax, which only processes predifined tagnames, all other stuff is beeing dumped out or just ignored. important is, that nested html-elemnts are dumped as they are inside the xml.
my problem: i wrote some dom stuff, to find the right node if i have the validated form-data, which consists changes to the xml. but i become desperate with merging the html-elements back to the xml.
one solution would be, to handle all nodes (also the html-nodes) with dom. in my opinion, this seems much too costly. another point is, that we start with a part of elements to use. if i would try to handle all elements with dom, i would have to process the whole specification.
the second solution - the one i've chosen - integrates this partly sax-parser, to get all plaintext *and* html-elements as simple textblocks. all other elements i get as dom-node. it wouldn't be a big deal, to dump all that stuff back together, but i would like to have some possiblity to compare the original xml with the new ones. as a result i could 'update' my nodes and wouldn't have to rewrite all again and again.
my form data looks like that:
[VALUE] <p>Read this postcard from your English pen-friend, Sam.<div><object type="image/png" data="images/postcard.png" ><blockquote class="postcard" ><p>Here is a postcard of my town. Please send me<br> a postcard from your town.
What size is your<br> town? What is the nicest part of your town?<br>
Where do you go in the evenings?<br> Sam.
. [NAME] extendedTextInteraction
. . [id] postcardWriting
. . [responseIdentifier] RESPONSE
. . [expectedLength] 200
<p>Read this postcard from your English pen-friend, Sam.</p>
<object type="image/png" data="images/postcard.png">
<p>Here is a postcard of my town. Please send me<br/> a postcard from your town.
What size is your<br/> town? What is the nicest part of your town?<br/>
Where do you go in the evenings?<br/> Sam.</p>
<extendedTextInteraction id="postcardWriting" responseIdentifier="RESPONSE" expectedLength="200">
<prompt>Write Sam a postcard. Answer the questions. Write 25-35 words.</prompt>