1
我需要使用Java在給定的下面的Xml文件中添加以下方法標記。如何使用Java修改Xml標籤並在Xml文件中插入新標籤?
<method id="img_8497" img_src="/media/media/12508/23804/AWH13.ThreeKids.SM.jpg" img_height="180" img_width="317" title_="playing^kids"/>
在這個標籤中它有5個屬性,在Java中我可以把它作爲局部變量。在Xml創建中,我需要使用5個屬性。方法標籤將是LibertyBook 的子標籤,In選項也可能是Liberary標籤的子標籤。我需要在LiberayBook和Liberary標籤之間插入方法標籤。如果Liberay標籤的數量可能更少或增加。取決於它應該爲Liberay標籤創建方法(FOR循環)。
<parent>
<Body class="student" id="181_student_method_3">
<Book class="Book_In_School_11" id="181_student_method_11"/>
<subject class="subject_information " id="181_student_subject_12"/>
<div class="div_passage " id="181_div_method_3">
<p class=" paragraph_book_name" id="181_paragraph_13">
<LiberaryBook class="Liberary" id="181_Liberary_9" >
<Liberary class="choice " Uninversity="University_Liberary_1">Dubliners</Liberary>
<Liberary class="choice " Uninversity="University_Liberary_2">Adventure if sherlock Holmes</Liberary>
<Liberary class="choice " Uninversity="University_Liberary_3">Charlotte’s Web</Liberary>
<Liberary class="choice " Uninversity="University_Liberary_4">The Outsiders</Liberary>
</LiberaryBook>
</p>
</div>
</Body>
</parent>
你看着JAXB? – Bajal