Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Remove Preceeding Characters in XML string

Posted on 2011-09-20
2
Medium Priority
?
301 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 83

Accepted Solution

by:
leakim971 earned 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
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…
Suggested Courses

926 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