• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

Show only certain text in XML

I am working on a small xml/jquery app: http://www.ryancoughlin.com/files/xml/

If you select user - pick a user thne view the table. you will see ALL users.

If you look at the extension column, I am only trying to show the "ext. XXX" section.

I have that data being loaded via XML It looks like:

                  <Phone>555-4580 ext. 581</Phone>

How can I use jQuery to when I parse this on my page to only show the ext.581 part.

Any ideas?

Thanks,

Ryan
0
catonthecouchproductions
Asked:
catonthecouchproductions
  • 3
  • 2
1 Solution
 
hieloCommented:
>>How can I use jQuery to when I parse this on my page to only show the ext.581 part.
are you saying that you CANNOT extract the value <Phone) at all?
Or is the problem just the ext. 581?
0
 
catonthecouchproductionsAuthor Commented:
Hey,

I was trying to extract just the ext. 581 section.

Ryan
0
 
hieloCommented:
you need to extract the whole value of the <Phone> node first. AFTER you have extracted "555-4580 ext. 581" THEN you can get the 581.

Instead of:
var ext = $(this).find('Phone').text();

all you need is:
var ext = String($(this).find('Phone').text()).split("ext. ")[1];
0
 
catonthecouchproductionsAuthor Commented:
Thank you, ill go try this out, so that is converting the whole line in to a string, after finding Phone text and split at the extension, what does that 1 do? Is that like a key? 0,1,2, etc?

Ryan
0
 
hieloCommented:
>> Is that like a key? 0,1,2, etc?
Yes -  split return an array. index 0 would be the stuff to the left of the ext.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now