在 Java 中获取 XML 元素中的值 [英] Grabbing values in XML elements in Java

查看:35
本文介绍了在 Java 中获取 XML 元素中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究如何从我拥有的 XML 文件中的特定 XML 节点获取值.在我的应用程序中,我将整个 XML 文件放在一个字符串中,我想从那里获取特定信息.我听说过一些 DOM 和 SAX,但我不知道从哪里开始.有什么帮助吗?

I'm looking into how I can get values from specific XML nodes in an XML file that I have. In my application, I have the entire XML file in a string, and I want to grab the specific information from there. I've heard a little bit about DOM and SAX, but I don't exactly know where to start. Any help?

推荐答案

最简单的方法之一是使用 xPath.这是一个教程.

One of the easiest ways is to use xPath. Here's a tutorial.

这篇关于在 Java 中获取 XML 元素中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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