我正在使用以下代码
public String readXmlData() {
ArrayList<String > list = new ArrayList<String>();
String strLine = null;
String finalText="";
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream(path);
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
if(strLine.length()!=0){
//list.add(strLine);
finalText=finalText+strLine;
System.out.println (finalText);
}
}
System.out.println (finalText);
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
return finalText;
}
其给出的结果如下:
<center><table><tr><td bgcolor='#ffff00'>Your Internet Order:</td><td colspan='2' bgcolor='#ffff00' align='right'>test/test/test8</td></tr><tr><td bgcolor='#ffff00'>Description:</td><td>EK Internet Booking Engine</td><td align='right'>1.00</td></tr><tr><td colspan='2'>Subtotal:</td><td align='right'>935.65</td></tr><tr><td colspan='2' bgcolor='#c0c0c0'>Total cost:</td><td bgcolor='#c0c0c0' align='right'>935.65</td></tr><tr><td colspan='3'>&nbsp;</td></tr><tr><td bgcolor='#ffff00' colspan='3'>Your billing address:</td></tr><tr><td colspan='3'><br>Address Object contains :
我的要求是,我必须在文本框中按原样发布xml。
答案 0 :(得分:0)
调用方法unescapeXml(finalText)。
public String unescapeXml(String escapedXml) {
return escapedXml.replaceAll("<", "<")
.replaceAll(">", ">");
}
答案 1 :(得分:0)
您可以使用var client = new System.Net.Http.HttpClient();
string response = string.Empty;
string authHeader = string.Empty;
string verb = string.Empty;
string resourceType = string.Empty;
string resourceId = string.Empty;
string resourceLink = string.Empty;
client.DefaultRequestHeaders.Add("x-ms-date", utc_date);
client.DefaultRequestHeaders.Add("x-ms-version", "2017-02-22");
verb = "POST";
resourceType = "docs";
resourceLink = $"dbs/{databaseId}/colls/{collectionId}/docs";
resourceId = (idBased) ? $"dbs/{databaseId}/colls/{collectionId}" : collectionId.ToLowerInvariant();
authHeader = GenerateMasterKeyAuthorizationSignature(verb, resourceId, resourceType, masterKey, "master", "1.0");
client.DefaultRequestHeaders.Remove("authorization");
client.DefaultRequestHeaders.Add("authorization", authHeader);
client.DefaultRequestHeaders.Add("x-ms-documentdb-isquery", "True");
client.DefaultRequestHeaders.Add("x-ms-documentdb-query-enablecrosspartition", "true");
client.DefaultRequestHeaders.Add("x-ms-partition-key", "[\"siteId\"]");
var qry = new SqlQuerySpec { query = "SELECT * FROM root WHERE (root[\"status\"] = 0)" };
var r = await client.PostWithNoCharSetAsync(new Uri(baseUri, resourceLink), qry);
var s = await r.Content.ReadAsStringAsync();