Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Non-java techie needs help please! 1

Status
Not open for further replies.

caffe

Programmer
Mar 6, 2015
1
0
0
US
Trying to modify code that I inherited. I'm an xml/xsl/sql person and this just has me stumped.

xml data behind a form containing customer information. I need to get the value from a field id two nodes down.

Code:
<pagexml>
<webSessionXML>
<TransportData>
<Field Id="CUST.CITY" Value="New Orleans" UIRequired="0" UIDisabled="0" UIHidden="0" UpdatedBy="User"/>

Purpose is to pull the value out and incorporate it into a query string to pass through to a URL. I can't pull it using SelectSingleNode.

This is the code that's in the current file. Need to get city out of code above instead of the App Key / ID Number.
Code:
	var application_number = '';
      var key = null;
      var type = '';

      var keynode = opener.pageXML.documentElement.selectSingleNode('//AppKey');
	  var key = '';
	  
	  if(keynode){
		key=keynode.text;
		}

      if(key.length > 0){        
        type = 'APPLICATIONDATA_IDNUMBER';
        application_number = key;
      }else{
        type = 'APPLICATIONDATA_OTHERNUMBER';
        try{
          application_number = $('body', opener.document).html().match(/"OTH_KEY" [vV]alue\="([\d\.\d]+)"/)[1];          
        }catch(e){              
      
        }
        if(typeof application_number === 'undefined' || application_number == ''){
          application_number = $("input[onchange*=updateOtherKeyValue]", opener.document).val();
        }
      }
			window.location = '[URL unfurl="true"]http://thatcompanysurl.com/ourfolder/ourSystem/show/SummaryFlowA?auth_token=ourtokencode&query="'[/URL] + type + '":"' + application_number + '"';

Help please? Thanks!
 
this should do it

Code:
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xml,'text/xml');
var nodes = xmlDoc.querySelectorAll('Field[Id="CUST.CITY"]');
for (var i = 0; i < nodes.length; i++) {
	var city = nodes[i].getAttribute('Value');
	alert(city);
}

fiddle here
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top