when there are \ns on xml data field, the data handle function has been call more than once.
[email protected] (陆伟峰)
| Newsgroups | php.xml.dev |
|---|---|
| Message-ID | <002101c2fcec$012ccd70$a50910ac@sparky> |
I am using xml_parse to deal with the xml file. My target is to get the data field into usable string variable. Oh, no....Problem comes. I have set a data handle function with "xml_set_character_data_handler". Then I found that the function has been called twice when there's an "\n" in the data field. And if there are n "\n", it will be called n+1 times. I don't understand if it is designed for or not. If it is not, I think it is a big problem for php developers. My dirty solution is that I have to append the second or third string to the first one. The details fellows: 1. set a global flag to boolean true in startElement function 2. read the flag to decide if using append mode (depend the value of global flag) 3. append the $data or not. 4. before leaving the function, set the flag to false. if the data function was called second time or third.., you will get the global flag with boolean false. It does well. Wish the folks get my message. WeiFeng Lu <mailto:[email protected]> [email protected] Apr. 7, 2003