萨克斯解析问题
我正在使用 SaxParsing 来解析来自 web 服务的响应。在这里,我给出了我遇到的 xml 文件
<HelpDesk xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<entry>
<id>1</id>
<parent>0</parent>
<name>
<![CDATA[ Equipment Tab ]]>
</name>
<description>
<![CDATA[ ]]>
</description>
<content>
<![CDATA[
There are several ways equipment can be added to a booking. Equipment can be added through the tree view of the inventory. It can be added by searching the product code or description. Once equipment is selected for the booking adjustments can be made to the quantity, price, and discount for each line of equipment. Specific pricing models on a per line basis can be created. Discounts can be applied to the entire booking. This will not conflict with any line item discounts. If a discount on the line already exists the overall booking discount will skip the line amount and apply to other applicable lines. Once pricing is complete taxes can be applied as required. Multiple tax rates can be applied by clicking on a tax box. Operator discount authorizations are controlled by the individual operator and not at the group level.
]]>
</content>
<rating>80</rating>
<votes>36</votes>
<views>169</views>
<private>0</private>
<status/>
</entry>
</HelpDesk>
问题是我没有获得内容标签中的完整内容。 任何人都可以提供解析此 xml 的代码吗?
谢谢
I am using SaxParsing to parse the response from webservice. Here i am giving the xml file I am getting
<HelpDesk xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<entry>
<id>1</id>
<parent>0</parent>
<name>
<![CDATA[ Equipment Tab ]]>
</name>
<description>
<![CDATA[ ]]>
</description>
<content>
<![CDATA[
There are several ways equipment can be added to a booking. Equipment can be added through the tree view of the inventory. It can be added by searching the product code or description. Once equipment is selected for the booking adjustments can be made to the quantity, price, and discount for each line of equipment. Specific pricing models on a per line basis can be created. Discounts can be applied to the entire booking. This will not conflict with any line item discounts. If a discount on the line already exists the overall booking discount will skip the line amount and apply to other applicable lines. Once pricing is complete taxes can be applied as required. Multiple tax rates can be applied by clicking on a tax box. Operator discount authorizations are controlled by the individual operator and not at the group level.
]]>
</content>
<rating>80</rating>
<votes>36</votes>
<views>169</views>
<private>0</private>
<status/>
</entry>
</HelpDesk>
Problem is i am not getting the full contents in content tag.
Can anybody give the code to parse this xml
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 xml 处理程序的字符方法中使用它
,其中 buf 是字符串生成器。
Use this in the character method of your xml handler
Where buf is a string builder.
您应该在 startElement() 方法中初始化 StringBuffer 并将在 strings() 方法中获取的字符串附加到 String 缓冲区
You should initilize the StringBuffer at the startElement() method and append the string you are getting at the characters() method to the String buffer