NSXMLParser ignore XML's DTD

362 views Asked by At

I faced problem when parse XML in iOS App. I define DTD to remove white spaces and tabs. This is my xml.

<?xml version="1.0" ?>
<!DOCTYPE list [
<!ELEMENT list (bsinfo+)>
<!ELEMENT bsinfo (id,title,desc,books)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT desc (#PCDATA)>
<!ELEMENT books (book+) >
<!ELEMENT book (idu, pages) >
<!ELEMENT idu (#PCDATA)>
<!ELEMENT pages (#PCDATA)>
]>

<list>
<bsinfo>
<id>16</id>
<title>X</title>
<desc>none</desc>
    <books>

        <book>
            <idu>123</idu>
            <pages>567</pages>
        </book>
        <book>      
            <idu>874</idu>
            <pages>256</pages>
        </book>             
    </books>        
</bsinfo>   
</list>

and when i parsed it still got white space and tabs in:

func parser(parser: NSXMLParser!, foundCharacters string: String!)
{
        println(xmlElement + " => [" + string+"]")
}

Result:

id => [16]
id => [
    ]
title => [X]
title => [
    ]
...

Why NSXMLParser doesn't recognize DTD?

0

There are 0 answers