我正在寻求将XML文件解析为阅读器。下面的示例已使用属性并对其进行了处理。我正在寻找使用Elements的方法,但不确定如何更改代码才能使其正常工作。 get Attribute选项似乎是最合逻辑的更改,但是由于元素不同,我不确定getElementsByTagName中要更改的内容。我想我重复了这个吗?
我已使用此示例(read external XML files in Android)来了解如何读取和解析效果很好的XML文件。
<Survey>
<Job>
<JobNo>123456</JobNo>
<JobType>1</JobType>
<Customer>AutoAppliance</Customer>
<Contact>Barry Scott</Contact>
<Salutation>Mr</Salutation>
<FirstName>Keith</FirstName>
<SurName>Hawkins</SurName>
<CompanyName></CompanyName>
<Address1>10 St. Thomas Court</Address1>
<Address2>Wimbledon</Address2>
<Address3></Address3>
<TownCity>LONDON</TownCity>
<County></County>
<Postcode>E1 1EE</Postcode>
<Phone1>0800 000 000</Phone1>
<Phone2>01222 222 111</Phone2>
<Email1>anotheremail@googlemail.com</Email1>
<Email2></Email2>
</Job>
<Job>
<JobNo>789012</JobNo>
<JobType>2</JobType>
<Customer>Bristol</Customer>
<Contact>Paul Pogba</Contact>
<Salutation>Mrs</Salutation>
<FirstName>Belinda</FirstName>
<SurName>Carlisle</SurName>
<CompanyName></CompanyName>
<Address1>34 Test Lane</Address1>
<Address2></Address2>
<Address3></Address3>
<TownCity>Anytown</TownCity>
<County>West Sussex</County>
<Postcode>BN1 0TT</Postcode>
<Phone1>01903 333 444</Phone1>
<Phone2>07900 777 777</Phone2>
<Email1>mytestemail@icloud.com</Email1>
<Email2></Email2>
</Job>
答案 0 :(得分:0)