This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Here is my MSXML sscripting Q - searching
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Here is my MSXML sscripting Q - searching
- From: "Walter Torres" <walter at torres dot ws>
- Date: Wed, 2 May 2001 20:28:12 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
A few days ago I asked where I could go and ask script questions, a few
replyed that here was fine, so here goes.
I have a search function, modified from a book (sorry, can't remember
which).
This works fine for the most part.
It drills down into the data (also below), and finds NODEs as it should, and
even returns the parent NODEs of the found NODEs.
My problem is placing the found NODe(s) into the temp XML object.
See, this clones found NODes into a temp Object and then displays the data
in that temp object.
The data I am searching is 6 levels deep.
The clone NODEs are placed at level 2, or better, becomes level 2.
I have constructed the temp object with empty 3 levels to accept the found
NODEs which are themselves 3 levels.
I think the problem is with the insertBefore line in the search loop.
Any ideas on this?
Thanks
Walter
=================================
// We need a blank XML Object to store found items into
// We need to create the shell NODES...
var strXMLshell = "<?xml version='1.0'?>
<callEvent><response><interaction_list>
</interaction_list></response></callEvent>";
<!-- above breaks are for email only -->
// Load our XML String into the Object
objXMLset = load_XML_string ( strXMLshell );
=================================
srchType = 'events/call_event/cal_event_type';
searchStr = 'Cyndi';
=================================
// This will search the specified node type for given string
function search(searchStr, srchType)
{
// Make ure we have something to search for
if ( searchStr == '' )
{
alert ( 'Sorry, please enter some text to search for. ' );
return false
}
// What NODE do we search from and subNODE was selected
var mainNode = '/callEvent/response/interaction_list/interaction';
var searchNode = mainNode + '/' + srchType;
// Retrieve the NODES from our selected NODE path
var objNodeItems = objXMLdata.selectNodes(searchNode);
for (i = 0; i < objNodeItems.length; i++)
{
var currNode = objXMLdata.selectNodes(searchNode).item(i);
// Do the search
if ( currNode.text.search(searchStr) != -1)
{
var cloneTree = objXMLdata.selectNodes(mainNode).item(i).cloneNode(true);
objXMLset.documentElement.insertBefore(cloneTree,
objXMLset.documentElement.lastChild);
}
} // for (i = 0; i < objNodeItems.length; i++)
// Place found data into display via XSL
insertXML ( objXMLset, objXSLdoc, top.contactDisplay.dataTarget );
// xslTarget.innerText = objXMLset.xml;
// Reset the objXMLset object for the next search
// Create out blank XML Shell
loadBlankXML();
}
=================================
===========================================================
-- sample record, 1 of 4 in my demo set --
<callEvent>
<response>
<interaction_list>
<interaction id='19766'>
<timestamp>2001-04-16T04:30:32</timestamp>
<media_type id='103'>Phone</media_type>
<channel id='1'>-</channel>
<ani></ani>
<dnis></dnis>
<route_type>I</route_type>
<events>
<call_event id='34757'>
<timestamp>2001-04-16T04:30:32</timestamp>
<call_event_type id='98'>eMail</call_event_type>
<customer id='2124'>Harris</customer>
<curr_dest id='103'>Vincent</curr_dest >
<to_dest id='1'>-</to_dest>
<nav_code id='1'>-</nav_code>
<rule id='1'>-</rule>
<greeting id='1'>-</greeting>
<call_type id='1'>-</call_type>
<ext_call id='1'>-</ext_call>
<old_call_record id='1'>-</old_call_record>
<product id='1'>-</product>
<reason id='198'>Case Resolution</reason>
<detailed_comment>Closed issue</detailed_comment>
</call_event>
</events>
</interaction>
</interaction_list>
</response>
</callEvent>
=====================================
eof
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list