Solved

Remove Preceeding Characters in XML string

Posted on 2011-09-20
2
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article discusses how to implement server side field validation and display customized error messages to the client.
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

626 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