The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Vexed XSL/XML DOM parsing in IE6 - Hellllp!!

My problem is simple, but I'm stupid.

I have a XML document prop.xml

<area>
  <newyork>
    <property> blahblah</property>
    <address>something else</address>
    <phone>blahblah2</phone>
  </newyork>
  <atlanta>
    <property>xyz</property>
    <address>cnn tower</address>
    <phone>2130909832</phone>
  </atlanta>
</area>

I have an XSL file that can act on this XML data.

In my Javascript, what I want to do is process only that node which I want, based on a function

let's say
function processarea(areaname) {
 //e.g. areaname = "newyork"
 //get the newyork node
 //get the XMLDOM object for XSL
 //apply XSL transform
}

I know now to apply the transform and have an idea of parsing the XML DOM. But what I can't figure out is how do I get get just that specific node and its children in well-formed XML so that loadXML or load work propoerly? I just can't seem to figure that out! I know I can get a node by doing documentElement, and then childNodes, or use selectSingleNode etc. etc. but done seem to get me the full XML node that I can use XSL on.

Please help!
stumped by DOM
Thursday, August 11, 2005
 
 
Hi,

I have not yet used the XML stuff from within JavaScript, but I guess it will use the same set of objects.

So, first retrieve the XML-node you want to perform the XSL transaction on (e.g. selectSingleNode), then pass the XML for this node into the loadXML method. loadXML accepts both complete XML documents and well formed XML fragments.

You can retrieve the XML fragment for a particular node using the property OuterXML and pass this into the loadXML.

As an alternative solution you can apply the XSL stylesheet to the complete XML tree (e.g. by passing the name of the desired node into the stylesheet).

Hope this helps.

boris
Boris Rogge Send private email
Friday, August 12, 2005
 
 
What exactly are you trying to do on the server side?
What exactly are you trying to do on the browser side?
Dino Send private email
Friday, August 12, 2005
 
 
Dino,
Nothing really on the server side - just a static XML file. I'm doing everything at the client (browser).

I had already tried what Boris suggested - my problem is now the knowledge of how to use XML/SDL etc. It's really how to get a specific node and its children in an XML document and pass that on to XSL transform.

When I do a selectedNode or any other DOm operation, I can't seem to pass it to .transform method of MSMXML. It's as if the XML marking gets lost.. *sigh*
stumped
Friday, August 12, 2005
 
 
OK - it got fixed. A silly code mistake at my end - I was doing everything right except in one place where I was using a wrong variable to load.
stumped
Friday, August 12, 2005
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz