[英]Parsing JSON into HTML Table
任何人都可以幫我解析使用BLOB在Oracle DB中存在的XML內容。 並使用Angular JS在HTML表格中顯示它。
每當我查詢一個字段時,從Oracle DB,它將返回多個帶有BLOB的ROW
每個Blob都包含XML數據。 現在我想從AngularJS中解析它。
這是我嘗試過的
我從php獲取XML響應並將其發送到Sitemap.xml並在AngularJS中訪問它
由於我有3個ROWS從數據庫返回,我得到3個XML標簽,如下所示
<Person:PersonEvent xmlns:Person = "http://PERSON/PersonEvent">
<Person:Body>
<Person:WorkOrder workOrderId = "1">
<Person:OrderStatus>RED</Person:OrderStatus>
<Person:OrderType>A</Person:OrderType>
</Person:WorkOrder>
</Person:Body>
</Person:PersonEvent>
<Person:PersonEvent xmlns:Person = "http://PERSON/PersonEvent">
<Person:Body>
<Person:WorkOrder workOrderId = "2">
<Person:OrderStatus>GREEN</Person:OrderStatus>
<Person:OrderType>B</Person:OrderType>
</Person:WorkOrder>
</Person:Body>
</Person:PersonEvent>
<Person:PersonEvent xmlns:Person = "http://PERSON/PersonEvent">
<Person:Body>
<Person:WorkOrder workOrderId = "3">
<Person:OrderStatus>RED</Person:OrderStatus>
<Person:OrderType>C</Person:OrderType>
</Person:WorkOrder>
</Person:Body>
</Person:PersonEvent>
現在我想使用ANGULAR JS將它轉換為JSON並在HTML TABLE中顯示值。 你能幫我么
AngularJS
var app = angular.module('httpApp', []);
app.controller('httpController', function ($scope, $http) {
$http.get("Sitemap.xml",
{
transformResponse: function (cnv) {
var x2js = new X2JS();
var aftCnv = x2js.xml_str2json(cnv);
return aftCnv;
}
})
.success(function (response) {
console.log(response);
});
});
我的UI應該看起來像HTML表格
<table>
<tr>
<th>WorkOrder</th>
<th>OrderStatus</th>
<th>OrderType</th>
</tr>
<tr>
<td>1<br></td>
<td>RED</td>
<td>A</td>
</tr>
<tr>
<td>2</td>
<td>GREEN</td>
<td>B</td>
</tr>
<tr>
<td>3</td>
<td>RED</td>
<td>C</td>
</tr>
</table>
我得到了答案。 問題是XML有多個根元素,因此它沒有轉換為JSON。
作為一個現在的工作我正在使用So附加我的XML現在我能夠將它轉換為JSON
<Persons>
<Person:PersonEvent xmlns:Person = "http://PERSON/PersonEvent">
<Person:Body>
<Person:WorkOrder workOrderId = "1">
<Person:OrderStatus>RED</Person:OrderStatus>
<Person:OrderType>A</Person:OrderType>
</Person:WorkOrder>
</Person:Body>
</Person:PersonEvent>
<Person:PersonEvent xmlns:Person = "http://PERSON/PersonEvent">
<Person:Body>
<Person:WorkOrder workOrderId = "2">
<Person:OrderStatus>GREEN</Person:OrderStatus>
<Person:OrderType>B</Person:OrderType>
</Person:WorkOrder>
</Person:Body>
</Person:PersonEvent>
<Person:PersonEvent xmlns:Person = "http://PERSON/PersonEvent">
<Person:Body>
<Person:WorkOrder workOrderId = "3">
<Person:OrderStatus>RED</Person:OrderStatus>
<Person:OrderType>C</Person:OrderType>
</Person:WorkOrder>
</Person:Body>
</Person:PersonEvent>
</Persons>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.