NSXMLParser 发现返回“\n”的字符人物
我有一个 xml 解析器,foundCharacters 回调方法返回如下字符串:
"\n "
"\n "
这是我正在解析的 XML 部分,但我在其中的任何位置都没有看到此字符串:
<GetChannelMessages xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">
<element p2:type="ToonInDevModel.GetChannelMessagesTest_Result" xmlns:p2="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<messageid p2:type="Edm.Int32">15030</messageid>
<userid p2:type="Edm.Int32">1</userid>
<Handle xml:space="preserve">Henry </Handle>
<Distance p2:type="Edm.Double">16.845658889067568</Distance>
<MessageDateTime p2:type="Edm.DateTime">2011-07-18T03:14:43.17</MessageDateTime>
<Message>Posting this message again</Message>
</element>
<element p2:type="ToonInDevModel.GetChannelMessagesTest_Result" xmlns:p2="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<messageid p2:type="Edm.Int32">15021</messageid>
<userid p2:type="Edm.Int32">1</userid>
<Handle xml:space="preserve">Henry </Handle>
<Distance p2:type="Edm.Double">16.845658889067568</Distance>
<MessageDateTime p2:type="Edm.DateTime">2011-07-18T01:45:17.097</MessageDateTime>
<Message>Posting this message again</Message>
</element>
<element p2:type="ToonInDevModel.GetChannelMessagesTest_Result" xmlns:p2="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<messageid p2:type="Edm.Int32">15018</messageid>
<userid p2:type="Edm.Int32">1</userid>
<Handle xml:space="preserve">Henry </Handle>
<Distance p2:type="Edm.Double">16.845658889067568</Distance>
<MessageDateTime p2:type="Edm.DateTime">2011-07-18T01:33:18.1</MessageDateTime>
<Message>Posting this message again</Message>
</element>
此 XML 有问题吗?
I have an xml parser and the foundCharacters call back method is returning strings like this:
"\n "
"\n "
Here the part of the XML that I am parsing and I don't see this string anywhere in it:
<GetChannelMessages xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">
<element p2:type="ToonInDevModel.GetChannelMessagesTest_Result" xmlns:p2="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<messageid p2:type="Edm.Int32">15030</messageid>
<userid p2:type="Edm.Int32">1</userid>
<Handle xml:space="preserve">Henry </Handle>
<Distance p2:type="Edm.Double">16.845658889067568</Distance>
<MessageDateTime p2:type="Edm.DateTime">2011-07-18T03:14:43.17</MessageDateTime>
<Message>Posting this message again</Message>
</element>
<element p2:type="ToonInDevModel.GetChannelMessagesTest_Result" xmlns:p2="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<messageid p2:type="Edm.Int32">15021</messageid>
<userid p2:type="Edm.Int32">1</userid>
<Handle xml:space="preserve">Henry </Handle>
<Distance p2:type="Edm.Double">16.845658889067568</Distance>
<MessageDateTime p2:type="Edm.DateTime">2011-07-18T01:45:17.097</MessageDateTime>
<Message>Posting this message again</Message>
</element>
<element p2:type="ToonInDevModel.GetChannelMessagesTest_Result" xmlns:p2="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<messageid p2:type="Edm.Int32">15018</messageid>
<userid p2:type="Edm.Int32">1</userid>
<Handle xml:space="preserve">Henry </Handle>
<Distance p2:type="Edm.Double">16.845658889067568</Distance>
<MessageDateTime p2:type="Edm.DateTime">2011-07-18T01:33:18.1</MessageDateTime>
<Message>Posting this message again</Message>
</element>
Is there something wrong with this XML?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是正常的。
“\n”是换行符。 XML 解析器将告诉您它找到的所有 个字符,甚至元素本身之间的空格和行。
This is normal.
"\n" is a linebreak character. The XML parser will tell you about all characters it finds, even the spaces and lines between the elements themselves.