2

这是我想要更改的 xml 文件的部分......这个文件没有存储在我的项目资产中,它是 web 上的 xml 文件,我使用 XMLPull 解析器进行解析

<exclusion_criteria>
Poor condition (centre determined), acute leukemia in relapse (&lt10% blasts), second transplants, active infection, HIV infection, T-cell antibody prophylaxis (antithymocyte globulin, anti-CD52 etc), use of cord blood grafts, T-cell depletion of grafts
            </exclusion_criteria>
        </report>

        <report>

            <tumour_disease>
Bone Marrow Transplants
            </tumour_disease>

            <trial_status>
Active- Recruiting
            </trial_status>

            <short_title>
Haplo Transplants
            </short_title>

            <title>
Haploidentical donor stem cell transplantatation for myeloid malignancies - a phase I/II pilot study in an Australian population
            </title>

            <trial_register_number>
            </trial_register_number>

            <sponsors>
St Vincents Hospital
            </sponsors>

            <trial_phase>
Phase I/II
            </trial_phase>

            <locations>
St Vincents Hospital~
            </locations>

            <lead_site>
St Vincents Hospital
            </lead_site>

            <inclusion_criteria>
Patients aged 16-50 years with haematological malignancy requiring stem cell transplantation (acute myeloid leukaemia in CR1 or CR2, intermediate-high risk myelodysplasia, chronic myeloid leukaemia in CP2-resistant to TKIs, relapsed and refractory lymphoproliferative diseases or Hodgkins lymphomas) lacking a fully HLA-matched donor; with a partially (=5/6) HLA-mismatched donor; adequate organ function (cardiac, pulmonary, renal & hepatic 
            </inclusion_criteria>

            <exclusion_criteria>
Life expectancy < 3months; psychiatric conditioning impairing provision of informed consent; active malignant disease (excluding BCC and SCC; receiving concurrent investigational drugs; pregnant or lactating women
            </exclusion_criteria>
4

1 回答 1

0

参考这个:XmlPullParser

您是否正在搜索这样的内容:

if(eventType == XmlPullParser.TEXT) 
{
    String text = xpp.getText();
    if( text.contains("&") )
        text = text.replace("&", "&amp;");
    if( text.contains("<" ) )
        text = text.replace("<", "&lt;");
}

编辑:这是您如何在 a 中获取 xml 的方法String

String xmlStr = "";

HttpGet uri = new HttpGet(params[0]);

DefaultHttpClient client = new DefaultHttpClient();

HttpResponse resp = client.execute(uri);
StatusLine status = resp.getStatusLine();
if( status.getStatusCode() == 200 )
{
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(resp.getEntity().getContent());

    TransformerFactory transformerfactory = TransformerFactory.newInstance();
    Transformer transformer = transformerfactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");

    StringWriter stringWriter = new StringWriter();
    transformer.transform(new DOMSource(doc), new StreamResult(stringWriter));  

    // Now you can fix the invalid characters in your xml and put it in the parser  
    xmlStr = stringWriter.toString();
}           
于 2013-03-29T14:18:32.213 回答