检测文本内容是否具有CDATA [英] Detect whether the text content has CDATA

查看:56
本文介绍了检测文本内容是否具有CDATA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个用于获取应用程序描述的api和一个常见的UI。我需要检查Java中的描述是否带有 CDATA 标记。

I have two api for getting a description of apps and one common UI. I need to check whether the description come with CDATA tag or not in Java.

例如,一个应用程序具有以下描述:

For example, one app has the following description :

"<![CDATA[<p>What is Skype?<br />Skype is software that enables the world's     
conversations. Millions of individuals and businesses use Skype to make free video and voice    
calls, send instant messages and share files with other Skype users. Everyday, people also    
use Skype to make low-cost calls to landlines and mobiles.</p>]]>"

另一个应用具有以下描述

And another app has the following description

Run with your fingers as fast as you can to try and get to the top of the leader board. This    
 game gets even better with friends, Once people see you playing they will want to have a go    
 and try to beat your fastest time. Tip: Take long strides on the screen to get maximum     
distance per step,     
<a href=https://abc.defgh.ij.kl/apps/wap/shopping/shopping/freshima-supermarket/freshima-supermarket/web/>WAP URL</a>

如何区分两个描述?

推荐答案

如何解析XML?

如果您使用的是 StAX ,则可以获取遇到的当前事件您的流,该流可能是 XMLStreamConstants.CHARACTERS XMLStreamConstants.CDATA

If you are using StAX, you can get the current event that you encounter in your stream, which might be XMLStreamConstants.CHARACTERS or XMLStreamConstants.CDATA.

如果您正在获取 Node 对象(例如通过 XPathAPI 例如),则该对象将为您提供 getNodeType()方法。此外, Node 具有 Node.TEXT_NODE
Node.CDATA_SECTION_NODE

If you are getting a Node Object (like for instance via XPathAPI), the Object will offer you a getNodeType() Method. Also Node has Constants for Node.TEXT_NODE and Node.CDATA_SECTION_NODE.

更多信息将有助于回答您的问题。

More Information would be helpful answering your question.

问候,
最大

这篇关于检测文本内容是否具有CDATA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆