Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Simple XML parsing and XPath library in Java

License

NotificationsYou must be signed in to change notification settings

liflab/xml-lif

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a simple library for parsing and outputing XML strings. It alsoprovides a simple XPath 1.0 processor.

Build instructions

Download the source code or clone the repository. If you have Ant, youcan compile by simply typing:

$ ant

at the command prompt. This will create thexml-lif.jar library,which you can then include in your projects.

Usage

To parse a string

Stringmy_string ="some XML...":try {XmlElementelem =XmlElement.parse(my_string);}catch (XmlParseExceptione) {// Do something}

To create an XML structure

XmlElementmy_element =newXmlElement("foo");XmlElementinside =newXmlElement("bar");inside.addChild(newTextElement("Hello"));my_element.addChild(inside);

To query an object using an XPath expression

XPathExpressionexp =XPathExpression.parse("foo/bar/text()");try {Collection<XmlElement>result =XP.get(my_map,"b[0]");}catch (XPathParseExceptione) {// Do something}

With the elementmy_element created above, this would return theTextElement with value "Hello".


[8]ページ先頭

©2009-2025 Movatter.jp