由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 在线等...Java怎么读XPath?
相关主题
请教用CSS显示,打印footer在页面最下方请教:这个script运行后的not found 是怎么回事?
问个XPath的问题C的argc问题
如何从html文件里提出中文How to Parsing function in haskell?
有没有对xml文件进行类似sql直观查询的工具? (转载)Python擂台:算24点
web service大牛解释一下这个scheme的pattern match吧
出个题目: 给二手版加自动match功能【急】JS round 运算出错如何破
推荐个html parser的库?有每天上班写py的么 会不会疯掉?
一道bit operator面试题Visual C++ 2015不支持dynamic array?
相关话题的讨论汇总
话题: xpath话题: title话题: our话题: java
进入Programming版参与讨论
1 (共1页)
a*****9
发帖数: 805
1
被安排了个组件集成,要写点Java,
怎么把用Xpath读 XML?
最好有个working example.
这个是我写的。。。
String xml="Zac Dallas <
Title>Art and Design Director Bigbase Investments<
/CustomerCompany> Zac Dallas CustomerPicture> "In our industry, the pressure is
always intense to quickly and affordably turn the marketer’s vision and
the consumer’s taste into reality that performs well, feels good and looks
great. OnTrek has done exactly that for us, compressing our design cycles,
lowering our costs and helping us produce better products for our
customers."
";

InputStream is = new java.io.ByteArrayInputStream( xml.getBytes(
) );


DocumentBuilderFactory factory = DocumentBuilderFactory.
newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();


Document doc = builder.parse(is);
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
XPathExpression expr = xpath.compile("/root/ClientQuotes/Title");

Object result= expr.evaluate(doc, XPathConstants.STRING);
result是个Object, 然后我不知道该咋办了,
多谢各位
g*****g
发帖数: 34805
2
You should have a model class and you cast to that model class. Google for
some example.

Investments<

【在 a*****9 的大作中提到】
: 被安排了个组件集成,要写点Java,
: 怎么把用Xpath读 XML?
: 最好有个working example.
: 这个是我写的。。。
: String xml="Zac Dallas <
: Title>Art and Design Director Bigbase Investments<
: /CustomerCompany> Zac Dallas: CustomerPicture> "In our industry, the pressure is
: always intense to quickly and affordably turn the marketer’s vision and

1 (共1页)
进入Programming版参与讨论
相关主题
Visual C++ 2015不支持dynamic array?web service
BSD expr和GNU expr的不同出个题目: 给二手版加自动match功能
eval (expr, envir=, enclose=) 求解答推荐个html parser的库?
gmail 是怎么实现那些html功能的一道bit operator面试题
请教用CSS显示,打印footer在页面最下方请教:这个script运行后的not found 是怎么回事?
问个XPath的问题C的argc问题
如何从html文件里提出中文How to Parsing function in haskell?
有没有对xml文件进行类似sql直观查询的工具? (转载)Python擂台:算24点
相关话题的讨论汇总
话题: xpath话题: title话题: our话题: java