[Expat-discuss] Handling text that occurs in multiple places inside
of start and end tags
Nick MacDonald
nickmacd at gmail.com
Thu Oct 28 04:26:31 CEST 2004
I am creating my own expat wrapper that will work somewhat like SAX (I
probably should have used someone elses, but I didn't know where to
look when I started this project, and now I 95% done and determined to
finish my own.)
I am getting the start/text/end call backs in the order you would
expect, and I am happy with the results. I was considering
implementing an "all tag data at once" capability, but I can't think
of any really good way to handle the case where you have text for one
tag intermixed with other tags.
I am working with the following XML file:
<?xml version="1.0" encoding="UTF-8"?>
<TestTag1 Param1="Value1" Param2="Value2 with spaces">
Some data for TestTag1
<TestTag2/>
Some more data for TestTag1
<TestTag3>
<TestTag4 Param1="Value1"/>
</TestTag3>
Still more data for TestTag1
</TestTag1>
What I would like to see happen:
callback4TestTag1(2, paramNames, paramValues, text)
callback4TestTag2()
callback4TestTag3()
callback4TestTag4()
and the value for "text" in the first call back would be:
"Some data for TestTag1
Some more data for TestTag1
Still more data for TestTag1"
Short of implementing a full DOM, can anyone suggest a good memory
efficient way to deal with this case. So far, my only hope, short of
putting it all on a huge stack and or using DOM is to read the same
file multiple times, and that just isn't a pretty thought.
Is there some trick I could use in expat to achieve this?
More information about the Expat-discuss
mailing list