Solved

Remove Preceeding Characters in XML string

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

770 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