"mono"요소에서 HTML 코드를 추출해야하지만이 HTML 파일이 필요합니다. HTML 태그가 필요합니다. Groovy 프로그래밍 언어를 사용해야합니다.groovy를 사용하여 XML 파일에서 HTML 코드를 추출하는 방법
모든 div의 내부에 "모노"요소는
미리 감사 div의 포함 HTML 태그입니다. ----는 면역학 ---- MONOS 목록 2 장 있습니다
import javax.xml.parsers.*;
xml = new XmlParser().parse("languages.xml")
println("There are " +xml.chapters.chapter.size() +" Chapters")
for (int i = 0; i < xml.chapters.chapter.size(); i++) {
def chapter = xml.chapters.chapter[i]
def chapterName = chapter.'@name'
println chapterName
println("---- Monos List ----\n\n")
for (int j = 0; j < chapter.monos.mono.size(); j++) {
def mono = chapter.monos.mono[j]
println("Mono Content: " + mono.toString());
}
println("---- End Monos List ----\n\n")
}
하지만 난 그냥 다음 OUPUT를 얻을 :
<dataset>
<chapters>
<chapter id="700" name="Immunology">
<title>Immunology</title>
<monos>
<mono id="382727">
<div>
<h1>blah blah</h1>
</div>
<div>
<p>blah blah</p>
</div>
</mono>
</monos>
</chapter>
<chapter id="701" name="hematology">
<title>Inmuno Hematology</title>
<monos>
<mono id="blah blah">
<div>
<h1>blah blah</h1>
</div>
<div>
<div class="class1">blah blah</div>
</div>
</mono>
</monos>
</chapter>
</chapters>
</dataset>
나는 시도
모노 콘텐츠 : 모노 [attributes = {id = 382727}; 값 = [div [attributes = {}; 값 = [h1 [속성 = {}; 값 = [blah blah]]]], div [attributes = {}; 값 = [p [속성 = {}; 값 = [저쩌구]]]]]] ---- 끝 MONOS 목록 ----
혈액 ---- MONOS 목록 ----
모노 내용 : 모노 [속성 = {id = blah blah}; 값 = [div [attributes = {}; 값 = [h1 [속성 = {}; 값 = [blah blah]]]], div [attributes = {}; 값 = [div [attributes = {class = class1}; 값 : [blah blah]]]]] ---- End Monos List ----
? 모노 태그 요? –
나는 다음 코드 번째 시도했지만 그것은 나에게 출력을 제공 : 2 장 면역학 ---- MONOS 목록이 있습니다 ---- 모노 내용 : 모노 [= {ID = 382727을} 속성; 값 = [div [attributes = {}; 값 = [h1 [속성 = {}; 값 = [blah blah]]]], div [attributes = {}; 값 = [p [속성 = {}; 값 = [저쩌구]]]]]] ---- 끝 MONOS 목록 ---- 혈액 ---- MONOS 목록 ---- 모노 내용 : 모노 [= {ID를 속성 = blah blah}; 값 = [div [attributes = {}; 값 = [h1 [속성 = {}; 값 = [blah blah]]]], div [attributes = {}; 값 = [div [attributes = {class = class1}; value = [blah blah]]]]] ---- End Monos List ---- –
닫는 챕터 태그가 없습니다. –