Sto cercando di analizzare un file XML che contiene alcuni caratteri speciali come "&" utilizzando il parser DOM. Ricevo l'eccezione saxparse "il riferimento all'entità deve terminare con un delimitatore". C'è un modo per superare questa eccezione, dal momento che non posso modificare il file XML per rimuovere i caratteri speciali, poiché proviene da diverse applicazioni. Si prega di suggerire un modo per analizzare questo file XML per ottenere l'elemento radice?org.xml.sax.SAXParseException: il riferimento all'entità "T" deve terminare con ";" delimitatore
Grazie in anticipo
Questa parte del XML che sto parsing
<P>EDTA/THAM WASH
</P>
<P>jhc^72. METER SOLVENT: Meter 21 LITERS of R. O. WATER through the add line into
FT-250. Start agitator.
</P>
<P>R. O. WATER <ZLl LITERS </P>
<P>• NOTE: The following is a tool control operation. The area within 10 feet of any open vessel or container is under tool control. </P>
<P>-af . 73. CHARGE SOLIDS: Remove any unnecessary items from the tool controlled area. Indicate the numbers of each item that will remain in the tool controlled area during the operation in the IN box of the Tool Control Log. </P>
<P>^___y_ a. To minimize the potential for cross contamination, confirm that no other solids are being charged or packaged in adjacent equipment. </P>
<P>kk k WARNING: Wear protective gloves, air jacket and use local exhaust when handling TROMETHAMINE USP (189400) (THAM) (K-l--Irritant!). The THAM may be dusty. </P>
<P>-<&^b . Charge 2.1 KG of TROMETHAMINE USP (189400) (THAM) into FT-250 through the top. </P>
<P>TROMETHAMINE USP (189400) (THAM) </P>
<P>Scale ID: // 7S </P>
<P>LotNo.: qy/o^yo^ </P>
<P>Gross: ^. S </P>
<P>Tare: 10 ,1 </P>
<P>Net: J^l </P>
<P>Total: JL'J </P>
<P><Figure ActualText="&T ">
<ImageData src="images/17PT 07009K_img_1.jpg"/>
&T </Figure>
Checked by </P>
Solo una piccola osservazione. Ovviamente è invalido qualunque sia lo schema, ma prima non è ben formato. Non stiamo parlando di schemi qui. – lkuty
String xml = " Aaa & Bbb & Ccc client_name>"; risultati in Aaa & Bbb & Ccc client_name>. Questo può essere fatto funzionare per più di uno e nella stringa di input? –
Sì. Prova "&([^; &] + (?! (?: \\ w |;)))" (aggiunto e su pos 6) - questo dovrebbe funzionare per più e nell'input. – robbi5