Solved

Remove Preceeding Characters in XML string

Posted on 2011-09-20
2
291 Views
Last Modified: 2012-05-12
I'd like to delete the first 16 characters of a text field from an xml file. I thought of replacing the first 16 characters with a blank but this stops the script.

Right now the page displays a catalog code like this: 23_99IBM_230_13_AJ

I'd like to just show the AJ.

Is there a better method?

//This needs to stay as is:

try { document.write(x[i].getElementsByTagName("CatalogCode")[0].childNodes[0].nodeValue); } catch(e){}; 

//This needs to remove the first 16 characters:

x.replaceData(0,16,"");

Open in new window

0
Comment
Question by:jj1103
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36570807
try { document.write(x[ i ].getElementsByTagName("CatalogCode")[0].childNodes[0].nodeValue).substr(16); } catch(e){};

http://www.w3schools.com/jsref/jsref_substr.asp
0
 

Author Comment

by:jj1103
ID: 36570963
Tweaked it just a bit with an extra ) and it worked!

Thanks!
try { 
		document.write(x[i].getElementsByTagName("CatalogCode")[0].childNodes[0].nodeValue.substr(16)); 
		} catch(e){};

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Trying to get PDF to open as "Open,Save,Cancel" instead of as a pop-up. 6 31
jQuery Syntax 2 47
Google Sheets Script 21 53
Detect change of Select using JavaScript Only 12 45
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now