View Full Version : Getting text in xml element
09-01-2010, 01:34 AM
Ok, Simpler question. I'm trying to get the text in an xml element. Instead of getting just the text in the first child element I'm getting the text of all the children elements. How can I get it from just the first?
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
myVar = xmlObj.childNodes(0).childNodes(19).firstChild.text;
09-01-2010, 02:14 AM
You *do* know this code will never work in any browser except MSIE, yes?
Anyway, what's the XML look like???
And in this line:
you haven't initialized myVar yet, so you should be getting nothing for that .value.
09-01-2010, 03:15 AM
Page I read forgot to mention that one apearently.. I do have the variable initialized, along with a few others. Just didn't think I need to indude all the initializations. In the wrong forum my next wuestion then.. need some way to read the xml that will work in the frame/browser that this is going to show in in Windows Presentation Foundation.
09-01-2010, 05:32 AM
Two places in your code that depended on MSIE:
new ActiveXObject ==>> ActiveX is strictly a MicroSlop technology.
document.getElementById("comment_t").innerText ==>> innerText not available in other browsers.
Not hard to make it work in all browsers.
Don't see why this has anything (directly) to do with WPF. You do have to load the XML from a URL that is in the same domain as the page, of course. I assume you knew that?
09-01-2010, 08:26 AM
Yea I did. I've figured it out now. Sorry for taking so much of your time to no avail. :/
09-01-2010, 02:38 PM
You should check out YQL (Yahoo Query Language) if you feel like researching alternative methods.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.