Parsing SOAP response using NSXMLParser with Swift

荒凉一梦 提交于 2019-12-25 04:42:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!