Solved

Remove Preceeding Characters in XML string

Posted on 2011-09-20
2
280 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

707 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

12 Experts available now in Live!

Get 1:1 Help Now