0
즉시 PHP에서 생성되는 XML 오류 (그래서 파일이 .PHP는)안드로이드 나는 안드로이드 응용 프로그램하지만 XML 파일에서 XML 파일을 읽기 위해 노력하고
읽기 이 오류 : URI에서 예상 파일 방식 : "http://someserver.com/foo/bar/Myuri.php"
이try {
File file = new File(new URI("http://someserver.com/foo/bar/Myuri.php"));
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(file);
doc.getDocumentElement().normalize();
System.out.println("Root element " + doc.getDocumentElement().getNodeName());
NodeList nodeLst = doc.getElementsByTagName("employee");
//System.out.println("Information of all employees");
for (int s = 0; s < nodeLst.getLength(); s++) {
Node fstNode = nodeLst.item(s);
if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
Element fstElmnt = (Element) fstNode;
NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("name");
Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
NodeList fstNm = fstNmElmnt.getChildNodes();
System.out.println("Name : " + ((Node) fstNm.item(0)).getNodeValue());
NodeList lstNmElmntLst = fstElmnt.getElementsByTagName("lastname");
Element lstNmElmnt = (Element) lstNmElmntLst.item(0);
NodeList lstNm = lstNmElmnt.getChildNodes();
System.out.println("Last Name : " + ((Node) lstNm.item(0)).getNodeValue());
}
}
} catch (Exception e) {
alertDialog.setMessage(e.getMessage());
alertDialog.show();
}
또한 헤더 파일을 PHP 파일로 보내시겠습니까? header ("Content-type : text/xml; charset = utf-8"); – vodich
@ 존 스키켓, 그래, 내가 어떻게 든 그것을 통과하는 방법입니다, 나는 단지 그것을 언급하는 것을 꺼리지 않았다! –
@vodich 물론 올바른 헤더가 있습니다. 동일한 PHP를 사용하고 있는데 내 Windows 전화 응용 프로그램에서 사용하고 있어도 잘 작동합니다. –