如果我必须提供xml以下:
<Text>
<TypeCode>SU99</TypeCode>
<ContentText>This is a test incident.</ContentText>
</Text>
我会写这样的代码:
SoapObject Text = new SoapObject ("", "Text");
Text.addProperty("TypeCode", "SU99");
Text.addProperty("ContentText", txtDet.getText().toString());
但是下面的xml怎么样? ContentText具有名为languageCode的附加属性。我该如何定义?有什么建议吗?
<Text>
<TypeCode>SU99</TypeCode>
<ContentText languageCode="EN">This is a test incident.</ContentText>
</Text>
答案 0 :(得分:0)
我可以使用以下代码解决它:
SoapObject Text = new SoapObject ("", "Text");
Text.addProperty("TypeCode", "SU99");
SoapPrimitive ContentText = new SoapPrimitive("", "ContentText", txtDet.getText().toString());
ContentText.addAttribute("languageCode","EN");
Text.addProperty("ContentText", ContentText);