java解析xml字符串 后 组装成map形式,求大神

Python016

java解析xml字符串 后 组装成map形式,求大神,第1张

java html(XML)解析工具jsoup:

说明:使用起来非常简单,就先jquery的dom操作一样方便,jsoup 是一款Java 的HTML、XML解析器,可直接解析某个URL地址、HTML文本内容。它提供了一套非常省力的API,可通过DOM,CSS以及类似于jQuery的操作方法来取出和操作数据。使用它来做解析非常简单方便。

jsoup中文参考文档:

http://www.open-open.com/jsoup/

我估计是要求按WCF模式下,利用NHibernate的架构方式组合

首先NHibernate里面有object-relation map 的xml

而WCF可以生成domainService,所以,一个是处于数据库层,一个是处于数据访问层

但是这两种方式的组合,我还没弄过,就在这里给你提一下吧

仔细看

2.An object-relation map for use by a object-relation system (or a ‘decorated’ domain model) such as NHibernate or EntityFramework/LINQ

是说你要讲数据库表,映射成有映射关系的NHibernate 模式,或EntityFramework/LINQ模式,可以任选其一,那么就可以选择任意一种模式了

另外,团IDC网上有许多产品团购,便宜有口碑

String truepathSub = truepath.substring(0, truepath.length()-4)

String truepath1Sub = zipnpath.substring(0, zipnpath.length()-4)

String zipname = truepath.substring(25, truepath.length()-4)

SAXReader saxRead = new SAXReader()

Document inDoc = saxRead.read(new File("C:\\apache-tomcat-6.0.29\\webapps\\xml\\"+truepathSub+

"\\"+truepath1Sub+"\\Test MetaData.xml"))

Element rootEl = inDoc.getRootElement()

Element element = rootEl.element("Datas")

//Element element1 = element.element("TestData")

for(Iterator i = element.elementIterator()i.hasNext()){

Element bookEl = (Element) i.next()

String Identifier = bookEl.elementText("Identifier")

String Type = bookEl.elementText("Type")

String Questions = bookEl.elementText("Questions")

String Difficulty = bookEl.elementText("Difficulty")

String SpecialtyType = bookEl.elementText("SpecialtyType")

String Specialty = bookEl.elementText("Specialty")

String Keyword = bookEl.elementText("Keyword")

String Answer = bookEl.elementText("Answer")

String Analysis = bookEl.elementText("Analysis")

String Contribute = bookEl.elementText("Contribute")

String Entity = bookEl.elementText("Entity")

String Date = bookEl.elementText("Date")

String Region = bookEl.elementText("Region")

String TypeOfSchool = bookEl.elementText("TypeOfSchool")

String EducationLevels = bookEl.elementText("EducationLevels")

String Course = bookEl.elementText("Course")

List<Stysj>bookList = new ArrayList<Stysj>()

Stysj stysj = null

stysj = new Stysj()

stysj.setIdentifier(Identifier)

stysj.setType(Type)

stysj.setQuestions(Questions)

stysj.setDifficulty(Difficulty)

stysj.setSpecialtyType(SpecialtyType)

stysj.setSpecialty(Specialty)

stysj.setKeyword(Keyword)

stysj.setAnswer(Answer)

stysj.setAnalysis(Analysis)

stysj.setContribute(Contribute)

stysj.setEntity(Entity)

stysj.setDate(Date)

stysj.setRegion(Region)

stysj.setTypeOfSchool(TypeOfSchool)

stysj.setEducationLevels(EducationLevels)

stysj.setCourse(Course)

stysj.setXmlname(zipname)

bookList.add(stysj)

simpleService.save(stysj)