PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I wrote a script the uses simplexml_load_file() to parse a file; when parsing a specific file i receive these error messages Warning: simplexml_load_file() [function.simplexml-load-file]: files/07 Jun/(12) doors_locks_2012_06_06_17_01.xml:8359: parser error : Opening and ending tag mismatch: Question line 8353 and ParentSubjectID
<Question>
<Text>Panic Door devices (Weekly):
3. Are all fixings secure, check for wear, are there any visible worn components</Text>
<QuestionID>qu_011</QuestionID>
<Index>12</Index>
<Variable>Q_12</Variable>
<QType>eqtAmerican</QType>
<QuestionAnswer>N/A</QuestionAnswer>
<Answers>
<Answer>
<IsOtherSpec>False</IsOtherSpec>
<Text>N/A</Text>
<Index>3</Index>
<AnswerID>5</AnswerID>
<Code>3</Code>
<AnswerShortID>an_011_006</AnswerShortID>
<AnswerVariable>A_qu_011_3</AnswerVariable>
</Answer>
</Answers>
</Question>
My thinking is telling me the problem is happening because of the whitespace inside the <Text> element. Is there any way to deal with this? One answer i found suggests using DOMDocument to load the document first and then using simplexml to parse the document.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
<Question>
<Text>Panic Door devices (Weekly):
3. Are all fixings secure, check for wear, are there any visible worn components</Text>
<QuestionID>qu_011</QuestionID>
<Index>12</Index>
<Variable>Q_12</Variable>
Above is line 8353 - 8359. No i'm not using any libxml options;
Celauran wrote:Cannot duplicate.
Could you elaborate on this a bit more?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
i see; i did that earlier and couldn't reproduce the problem either. I've decided to try a suggestion i found elsewhere which involves loading the document with loadXML() and the parsing it and from there use simplexml_load_string() as opposed to simplexml_load_file()
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
I think i might be dealing with a corrupted xml file. I tested an existing file from a previous export and one i exported this morning and the code does what it is supposed to.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering