我正在为 Android 制作一个应用程序,我需要显示此页面的 XML 文件:在应用程序中显示Compra="481.3" Venta="485"
但我不能"DOLAR SPOT INTERBANCARIO" and Var_por="-0,53" Var_pes="-2,60" hora="10:35"
。请帮我写代码。
XML 图像
这是 ExampleHandler 代码
public class ExampleHandler extends DefaultHandler {
private boolean in_Root = false;
private boolean in_Registro = false;
private ParsedExampleDataSet myParsedExampleDataSet = new ParsedExampleDataSet();
public ParsedExampleDataSet getParsedData() {
return this.myParsedExampleDataSet;
}
@Override
public void startDocument() throws SAXException {
this.myParsedExampleDataSet = new ParsedExampleDataSet();
}
@Override
public void endDocument() throws SAXException {
}
@Override
public void startElement(String namespaceURI, String localName,
String qName, Attributes atts) throws SAXException {
if (localName.equals("Root")) {
this.in_Root = true;
}else if (localName.equals("Registro")) {
this.in_Registro = true;
// Extract an Attribute
String attrValue = atts.getValue("Compra");
Float compra = Float.parseFloat(attrValue);
myParsedExampleDataSet.setExtractedCompra(compra);
String attrValue2 = atts.getValue("Venta");
Float venta = Float.parseFloat(attrValue2);
myParsedExampleDataSet.setExtractedVenta(venta);
**String attrValue3 = atts.getValue("Var_por");
Float por = Float.parseFloat(attrValue3);
myParsedExampleDataSet.setExtractedPor(por);**
//its my wrong code for Var_por
}
}
@Override
public void endElement(String namespaceURI, String localName, String qName)
throws SAXException {
if (localName.equals("Root")) {
this.in_Root = false;
}else if (localName.equals("Registro")) {
}
}
/** Gets be called on the following structure:
* <tag>characters</tag> */
@Override
public void characters(char ch[], int start, int length) {
if(this.in_Registro){
//myParsedExampleDataSet.setExtractedStruct(new String(ch, start, length));
}
}
}