【发布时间】:2015-09-01 06:19:29
【问题描述】:
我有一个类似的 XML 字符串
<?xml version="1.0" encoding="UTF-8"?>
<ProductDetails ProductID="TuscanWengeShoeRack010cfg" ProductcfgPath="http://localhost/media/productattachment/176/TuscanWengeShoeRack010cfg.xml" SKUID="TWS090" />
我需要输出为
var pid = // should be fetched from ProductcfgPath attribute
var sku = // should be fetched from SKUID attribute
alert(pid); // 176
alert(sku); // TWS090
【问题讨论】:
-
这是执行此操作的示例:- api.jquery.com/jQuery.parseXML 另一个链接是 stackoverflow.com/questions/7228141/…
-
@Deepaksaini 已经这样做了,我只得到对象 [Object]
-
@ShadabMehdi 你能展示你的尝试吗..
-
也许你应该添加 .text() 从节点获取价值
-
@ShadabMehdi 下次您应该写下您尝试过的内容以及错误的确切位置。