a*****9 发帖数: 805 | 1 被安排了个组件集成,要写点Java,
怎么把用Xpath读 XML?
最好有个working example.
这个是我写的。。。
String xml="Zac Dallas <
Title>Art and Design Director Bigbase Investments<
/CustomerCompany>
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> : CustomerPicture> "In our industry, the pressure is : always intense to quickly and affordably turn the marketer’s vision and
|
|