NSXMLParser 发现返回“\n”的字符人物

发布于 2024-11-25 12:08:52 字数 2032 浏览 5 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

金兰素衣 2024-12-02 12:08:52

这是正常的。

“\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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文