编程:SAX并获取open和close标签之间的内容? [英] programming: SAX and get content between open and close tag?

查看:53
本文介绍了编程:SAX并获取open和close标签之间的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使用SAX方法将

之间的XML内容提取为开始和结束标记,就好像它是连续的文本字符串一样?


例如,假设我们有以下文件:


< first>

< second>

< alpha> foo< / alpha>

< beta> bar< / beta>

< / second>

< / first>


是否可以直接提取< firstand< / first>

之间的内容,就好像它是文本字符串一样?

提前致谢

Rui Maciel

-

使用KDE 3.5.3运行Kubuntu 6.06并为此感到自豪它。

jabber:ru ******** @ jabber.org

Is it possible to, using the SAX approach, extract the XML content between
an opening and closing tag as if it was a continuous string of text?

For example, let''s say we have the following document:

<first>
<second>
<alpha>foo</alpha>
<beta>bar</beta>
</second>
</first>

Is it possible to directly extract the content between <firstand </first>
as if it was a text string?
Thanks in advance
Rui Maciel
--
Running Kubuntu 6.06 with KDE 3.5.3 and proud of it.
jabber:ru********@jabber.org

推荐答案

Rui Maciel写道:
Rui Maciel wrote:

< first>

< second>

< alpha> foo< / alpha>

< beta> bar< / beta>
< / second>

< / first>


是否可以直接在< firstand<之间提取内容; / first>

,好像它是一个文本字符串?
<first>
<second>
<alpha>foo</alpha>
<beta>bar</beta>
</second>
</first>

Is it possible to directly extract the content between <firstand </first>
as if it was a text string?



我认为这是不可能的。你是否期望

< first里面的标签也出现在文本中?或者您是否期望标签之间的

字符数据仅出现?什么

_exactly_你希望是你的例子的结果吗?

I think it''s not possible. Do you expect the tags inside
<firstto appear as text also ? Or do you expect the
character data between the tags to appear only ? What
_exactly_ do you expect to be the result of your example ?


Rui Maciel写道:
Rui Maciel wrote:

是否可以直接在< firstand< / first>

之间提取内容,就好像它是文本字符串一样?
Is it possible to directly extract the content between <firstand </first>
as if it was a text string?



不使用标准SAX。通过SAX序列化程序运行这些事件

从它们重新生成文本。

Not using standard SAX. Run those events back through a SAX serializer
to regenerate the text from them.




Joe Kesselman写道:

Joe Kesselman wrote:

不使用标准SAX。通过SAX序列化程序运行这些事件

以从中重新生成文本。
Not using standard SAX. Run those events back through a SAX serializer
to regenerate the text from them.



我明白你的意思了。但这似乎有点多余,不是吗?

我的意思是,通过解析器运行XML文本,分解它然后生成完全相同的
来自解析器信息的信息...它看起来好像很多麻烦只是为了结束我们以前的实际情况。

如果这样做会更简单有可能提取某些标签所包含的原始

内容。

Rui Maciel

I see what you mean. But that seems to be a bit redundant, doesn''t it?
I mean, run a XML text through a parser, decompose it and then generate
the exact same information from he parser''s information... It looks
like too much trouble just to end up practically where we were before.
It would be a lot simpler if it was possible to extract the original
content which is enclosed by certain tags.
Rui Maciel


这篇关于编程:SAX并获取open和close标签之间的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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