[phpXML] Re: [phpXML] Re: [phpXML] miss-match
Brought to you by:
bs_php,
nigelswinson
From: <ph...@pe...> - 2001-10-08 17:13:01
|
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.../ |