[phpXML] Re: [phpXML] miss-match
Brought to you by:
bs_php,
nigelswinson
From: <tom...@di...> - 2001-10-08 17:42:59
|
I was initially thrown off by the 'trivialness' of the example but when I look at how you intend to process the file it seems to cry out for a different structure altogether. Is it not true that _if_ there are children _then_ the children should stand as elements of the parent? ((then the other 'content' is/are really attributes of the parent)) That would say to me that the example being discussed could (should?) better be constructed like <blah1 precursor="Text" postcursor="text."> <blah2>more</blah2> </blah> Wouldn't that be more parallel to the processing that you intend to do to the file? my 2cents Tom At 08:10 PM 7/4/01 +0000, ph...@pe... wrote: >absolutely right, Nigel. The problem has nothing to do with CDATA - call it >embedded structure, where the child(ren) is in the middle of the parent. Try >the following: ><text>There are 2 categories: ><category>1</category> ><category>2 which has <sub>a subcategory</sub> as well</category> >which have to be taken into account.</text> >etc etc. >The parser adds an extra element to the array for each segment of a node, but >phpxml's load_file ignores this and just adds the content to the node without >any indication that there was a child in that position. Consequently, it >loses information. (it also compounds the error by stripping the spaces >around the tags, so "<text>The spacing is <e>very</e> important.</text>" >comes out as "The spacingisimportant." :-) > >afaics, the only solution is to add an extra array to correspond to each >segment, so my example above would be stored as text[0] e[0] text[1]. It gets >pretty hairy though trying to put it back together again, as there is no >limit to the number or levels of the array. I gave up trying to use php's >parse_into_struct because my poor brain couldn't cope with navigating all the >arrays! > > >On Wednesday 04 July 2001 13:20, you wrote: > > > > I'm not sure that this actually solves the stated problem though as I think > > I am right in saying that this is a fix that goes into get_file(). > > Therefore if the datastructure can't describe "Before<tag>Middle</tag>End", > > then it's not going to be able to print it. > > > > This fix will cope with usage of the object that make calls to > > set_content("address","Some text <B>that</B> contains some markup."). But > > if the xml file that you read in already has "Some text <B>that</B> > > contains some markup." then the class is going to loose this structure in > > the parse. > > > > Basically phpxml's internal datastructure is lossy. You can't read to > > object and write back out to file and have two logically identical files. > > Ideally it ought to be. > > > > We need a more complete fix for this in the constructor or load_from_file > > function I think.... > > > > Nigel > > > > > How can I get around phpXML's tendency to place tags inside regular text > > > after the tag containing the text. > > > i.e., > > > <blah1> > > > Text<blah2>more</blah2>text. > > > </blah> > > > Comes out > > > > > > Text text.more > > > > -- > > This message has been sent through the <phpXML/> user discussion list. To > > unsubscribe, please visit > > https://sslsites.de/mailinglisten/user/us...@li.../ > >-- >This message has been sent through the <phpXML/> user discussion list. To >unsubscribe, please visit >https://sslsites.de/mailinglisten/user/us...@li.../ -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |