我有以下xml要解析但是当我的程序在解析时停止并给出以下错误:
[致命错误]:6:6:不允许匹配“[xX] [mM] [lL]”的处理指令目标。
I have tried following java code:
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.xmlbeans.XmlException;
import org.w3c.dom.Document;
public class ParseSoapXML {
public static void main(String args[]) throws IOException, XmlException {
String fileRequestInput = "C:/REQUEST_MCI_UC_41.xml";
File xmlFileRequest = new File(fileRequestInput);
File file = new File(fileRequestInput);
FileInputStream fstreamRequest = new FileInputStream(xmlFileRequest);
DocumentBuilderFactory docFactory = null;
DocumentBuilder docBuilder = null;
Document document = null;
try {
docFactory = DocumentBuilderFactory.newInstance();
docBuilder = docFactory.newDocumentBuilder();
document = docBuilder.parse(fstreamRequest);
}
catch(Exception e){
}
System.out.println("Request xml generated Parsed succesffully ");
}
}
我的REQUEST_MCI_UC_41.xml文件包含:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<GetWeatherResponse xmlns="http://www.webserviceX.NET">
<GetWeatherResult>
<?xml version="1.0" encoding="UTF-8" ?>
<CurrentWeather>
<Location>New Delhi / Palam, India (VIDP) 28-34N 077-07E 233M</Location>
<Time>Nov 05, 2015 - 01:30 AM EST / 2015.11.05 0630 UTC</Time>
<Wind>from the NW (320 degrees) at 9 MPH (8 KT):0</Wind>
<Visibility>1 mile(s):0</Visibility>
<SkyConditions>mostly cloudy</SkyConditions>
<Temperature>71 F (22 C)</Temperature>
<DewPoint>62 F (17 C)</DewPoint>
<RelativeHumidity>73%</RelativeHumidity>
<Pressure>29.97 in. Hg (1015 hPa)</Pressure>
<Status>Success</Status>
</CurrentWeather>
</GetWeatherResult>
</GetWeatherResponse>
</soap:Body>
</soap:Envelope>
我认为我的程序是正确的,但在xml文件中可能有问题。你能帮忙解决这个问题吗