DangerMouse

I'm a total JS noob, but would like to echo out a DOM object to attempt to find out why i'm unable to walk it, is this possible? Sounds like it should be, but google has yet to provide me with an answer  Applause

Cheers,

DM

perkiset

I have not seen one either - it can be done, of course, but it'd be something to see. Even looking at the DOM in an inspector is kind of weird... I don't like it. I actually prefer to look at HTML and then "see it" in my head.

Are you pretty familiar with the DOM-walking functions? It might be better to talk about your intentions and how to walk/talk the DOM. I'm reasonably good and can probably help.

/p

DangerMouse

I'm completely new to

javascript

 , and am only fumbling with it now as I simply want to pull data from an XML file to display in Google

apple

 t thing - straightforward stuff I thought considering JS is renown for its DOM handling.

I've successfully pulled in my XML file as a DOM object, I just don't know what to do with it from here  :Applause - I've attempted DOM walking 'things' to put content into variables, but I've not got it to work, hence I thought i'd try to view the structure of what I was trying to walk.

XML doc format is:

<?xml version="1.0" encoding="UTF-8"?>

<get_stats generator="zend" version="1.0">
<url_id>1</url_id><url>http://www.yahoo.com</url>
<total_visits>2</total_visits>
<last_visit>2007-09-17 17:42:54</last_visit>
<status>Success</status>
</get_stats>


That is litterally it. Only one item returned, no duplication of any node.

Any suggestions appreciated Applause

Cheers,

DM

perkiset

Hey DM - I thought you were walking HTML rather than XML - so I am less experienced, but the dom funcs are the same in any case.

without id="aname" in the node, you'll not be able to getElementById obviously, so you'll need to either step into children and ask for their nodeName or look for nodes of a particular name from the root. For example, assuming that the variable with a handle to the DOM document is named "theDoc" you could ask this:

lv = theDoc.getElementsByTagName('last_visit');

lv would then be an array of elements under the root named last_visit - so in this case, lv[0] is the item you'd be looking for. I am at a client's, so I don't have my DOM reference handy, but there is a way to ask for all the children of the current node, and then ask each for their node name - so again, if theDoc is the root handle:

alert(theDoc.nodeName) would show an alert window with "get_stats"

I believe I posted a simple XML handler in the

Javascript

  code repository - I wrote it specifically because I didn't want to have to pull the trigger on the dom for simple parsing of a little XML chunk. I'll take a look and post back here.
/p


Perkiset's Place Home   Politics @ Perkiset's