问题
I am trying to parse the Soap response (snippet shown below) using NSXMLParser. However when I print the Element names in the didStartElemnt delegate method I only get the following elements returned.
Element's name is soap:Envelope
Element's name is soap:Body
Element's name is SearchResponse
Element's name is SearchResult
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<SearchResponse xmlns="http://www.example.com/">
<SearchResult><?xml version="1.0" encoding="utf-8"?><Results xmlns="http://www.example.com/XMLSchema/SearchResult" xmlns:gms="http://www.def.ghi.uk/CM/gms" xmlns:n2=" (more here + further elements....)
Why do I not see the Results (or any subsequent) element?
回答1:
Most likely it's the second <?xml . . .>
directive that appears inside the <SearchResult>
. That directive is only allowed at the start of an xml file.
来源:https://stackoverflow.com/questions/28285238/parsing-soap-response-using-nsxmlparser-with-swift