简体   繁体   中英

How to parse an XML AJAX Response

Image 在此处输入图片说明 Scenario

Im using ajax to post data to my backend and buy a domain, i'm getting a response but the response is in xml. I can simply access the child nodes by using: let Registered = data.object.CommandResponse.DomainCreateResult; but the DomainCreateResult node has attributes on it. if you look at the image above you'll see that to access them I need to access @attribute, but this throws an error because of the @ symbol.

I've read around the internet for what to do and it seems that everyone is parsing XML documents, but I don't think this is the same as parsing a document. I'm new to messing around with XML in PHP and Javascript.

How do i access the @attributes from this XML response? Thank you for all the help in advance.

使用[]表示法

let Registered = data.object.CommandResponse.DomainCreateResult['@attributes'].Domain;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM