[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Here is my MSXML sscripting Q - searching

Subject: Here is my MSXML sscripting Q - searching
From: "Walter Torres" <walter@xxxxxxxxx>
Date: Wed, 2 May 2001 20:28:12 -0500
sscripting
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.