Ho due file XML di struttura simile che desidero unire in un unico file. Attualmente sto usando EL4J XML Merge che ho trovato in questo tutorial. Tuttavia non si fonde come mi aspetto che per le istanze il problema principale è il suo non unire entrambi i file in un unico elemento che contiene 1, 2, 3 e 4. Invece scarta solo 1 e 2 o 3 e 4 a seconda del file che viene prima unito.Unisci due file XML in Java
Quindi sarei grato a chiunque abbia esperienza con XML Merge se potesse dirmi cosa potrei fare in modo errato o in alternativa qualcuno conosca una buona API XML per Java che sarebbe in grado di unire i file come richiedono?
Molte grazie per il vostro aiuto in anticipo
Edit:
potrebbe davvero fare con alcuni buoni suggerimenti su come fare questo in modo da aggiungere una taglia. Ho provato il suggerimento di jdigital ma ho ancora problemi con l'unione XML.
Di seguito è riportato un esempio del tipo di struttura dei file XML che sto cercando di unire.
<run xmloutputversion="1.02">
<info type="a" />
<debugging level="0" />
<host starttime="1237144741" endtime="1237144751">
<status state="up" reason="somereason"/>
<something avalue="test" test="alpha" />
<target>
<system name="computer" />
</target>
<results>
<result id="1">
<state value="test" />
<service value="gamma" />
</result>
<result id="2">
<state value="test4" />
<service value="gamma4" />
</result>
</results>
<times something="0" />
</host>
<runstats>
<finished time="1237144751" timestr="Sun Mar 15 19:19:11 2009"/>
<result total="0" />
</runstats>
</run>
<run xmloutputversion="1.02">
<info type="b" />
<debugging level="0" />
<host starttime="1237144741" endtime="1237144751">
<status state="down" reason="somereason"/>
<something avalue="test" test="alpha" />
<target>
<system name="computer" />
</target>
<results>
<result id="3">
<state value="testagain" />
<service value="gamma2" />
</result>
<result id="4">
<state value="testagain4" />
<service value="gamma4" />
</result>
</results>
<times something="0" />
</host>
<runstats>
<finished time="1237144751" timestr="Sun Mar 15 19:19:11 2009"/>
<result total="0" />
</runstats>
</run>
uscita prevista
<run xmloutputversion="1.02">
<info type="a" />
<debugging level="0" />
<host starttime="1237144741" endtime="1237144751">
<status state="down" reason="somereason"/>
<status state="up" reason="somereason"/>
<something avalue="test" test="alpha" />
<target>
<system name="computer" />
</target>
<results>
<result id="1">
<state value="test" />
<service value="gamma" />
</result>
<result id="2">
<state value="test4" />
<service value="gamma4" />
</result>
<result id="3">
<state value="testagain" />
<service value="gamma2" />
</result>
<result id="4">
<state value="testagain4" />
<service value="gamma4" />
</result>
</results>
<times something="0" />
</host>
<runstats>
<finished time="1237144751" timestr="Sun Mar 15 19:19:11 2009"/>
<result total="0" />
</runstats>
</run>
Potrebbe aggiungere il risultato desiderato? –
Hanno aggiunto l'output previsto l'aggiunta di risultati nel nodo risultati è la cosa più cricuale. –