0
DocumentBuilder API를 사용하여 Blackberry 응용 프로그램에서 XML을 만들고 쓰려고합니다. 나는이어야 한 요소와 속성을 만들 수있는 다음과 같은 방법을 서면으로 작성했습니다 :XMl net.rim.device.api.xml.parsers.DocumentBuilder를 사용하여 Blackberry에서 만들기
private void createResponseXML()
{
try
{
// Build a document based on the XML file.
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
Element surveyElement = document.createElement("Survey");
surveyElement.setAttribute("xmlns:abapsurvey", "http://www.sap.com/abapsurvey");
FileConnection fileConnection = (FileConnection) Connector.open("file:///SDCard/survey_response.xml", Connector.READ_WRITE, true);
OutputStream outputStream = fileConnection.openOutputStream();
XMLWriter writer = new XMLWriter(outputStream);
writer.setPrettyPrint();
DOMInternalRepresentation.parse(document, writer);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
내가 만드는 데 노력하고있어 XML의 구조는 다음과 같습니다 :
<?xml version="1.0" encoding="utf-8" ?>
- <Survey xmlns:abapsurvey="http://www.sap.com/abapsurvey" xmlns:bee="http://www.sap.com/survey/bee" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:htmlb="http://www.sap.com/survey/htmlb" xmlns:out="http://www.w3.org/1999/XSL/Output" xmlns:svy="http://www.sap.com/survey/svy" xmlns:tmp="http://www.sap.com/survey/tmp" xmlns:values="http://www.w3.org/1999/XSL/TransformValues" xmlns:wff="http://www.mysap.com/wff/2001">
- <Values>
- <Question QuestionId="q1">
- <Answer AnswerId="id_4214130a0e731678e10000000a114eea">
<Value>id_4214134d0e731678e10000000a114eea</Value>
</Answer>
</Question>
- <Question QuestionId="id_421413b20e731678e10000000a114eea">
- <Answer AnswerId="id_421413cb0e731678e10000000a114eea">
<Value>id_421413f70e731678e10000000a114eea</Value>
</Answer>
</Question>
- <Question QuestionId="id_4214142c0e731678e10000000a114eea">
- <Answer AnswerId="id_4214143e0e731678e10000000a114eea">
<Value>id_4214f3f6f3eb3d67e10000000a114eea</Value>
</Answer>
</Question>
- <Question QuestionId="id_4214f40cf3eb3d67e10000000a114eea">
- <Answer AnswerId="id_42144d6d48021679e10000000a114eea">
<Value>id_42144d9048021679e10000000a114eea</Value>
</Answer>
</Question>
</Survey>
내가 만든 내 랩톱 하드 드라이브에 SD 카드를 시뮬레이트하는 폴더. 나는이 메소드를 호출 할 때, XML은 다음과 같은 헤더 만 생성됩니다 : 왜 i의 요소가 XML에서 만든 가져 오지 다음 코드를 추가하기 위해 노력하고 있음을
<?xml version="1.0"?>
입니까?
Element surveyElement = document.createElement("Survey");
surveyElement.setAttribute("xmlns:abapsurvey", "http://www.sap.com/abapsurvey");
좋습니다.