/    Sign up×
Community /Pin to ProfileBookmark

How to parse returned XML

I am trying to parse and use the relevant information received from a server XML response. I cant seem to access the information correctly though,ive tried various means but with no luck.The basic format of response is as follows:

<getSitesUserCanAccessReturn xsi:type=”xsd:string”><?xml version=”1.0″ encoding=”UTF-8″?>
<list>
<item>
<siteId>12345</siteId>
<siteTitle>CSC1015F,2008</siteTitle>
<siteId>23344</siteId>
<siteTitle>CSC3002F,2008</siteTitle>
</item>
</list>
</ns1:getSitesUserCanAccessReturn>

Where getSitesUserCanAccessReturn is the return operation name.
Ive tried the following:
a.)
var rootNode = sites.responseXML.documentElement.getElementsByTagName( ‘getSitesUserCanAccessReturn’ );
var name = rootNode[0].getElementsByTagName(‘siteTitle’);

b.)

var sXPath = ‘getSitesUserCanAccessReturn/list’;
var col = sites.responseXML.getElementsByTagName(sXPath);
var oParticipant = col[0];
var test = oParticipant.selectNodes(“siteTitle”)[0];

Both cases didnt work and usually get an “undefined value” error message.
Cheers to anyone who can help.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @brucesithole spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...