TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sachi vasishta
NA
252
0
How to read XML data in Javascript - Help is Needed**
Nov 28 2011 6:24 AM
Hi All,
I have a following XML document
<root>
<fault>
<text selected_value="Pending fault">Pending Fault found on</text>
<text selected_value="Already repaired">Repaired Fault on</text>
// I may add two or more text nodes in future
</fault>
<genere>
<text>Aircraft</text>
<text>Component</text>
<text>Subsystem</text>
</genere>
</root>
In the aspx file I have a autocomplete textbox(tbauto) which will display the contenets of the 'text' node of 'fault' element. Below this autocomplete textbox I have a normal textbox(tbname).Till this I have no problem.
Now what I want is
if I select a 'Pending Fault found on' option from the autocomplete popup then, I want the 'select_value' attribute's value (i.e.,'Pending fault' ) of the first text node to be displayed on the textbox(tbname). if I select a 'Repaired Fault on' option from the autocomplete popup then, I want the 'select_value' attribute's value (i.e.,'Already repaired' ) of the second text node to be displayed on the textbox(tbname), and so on.
I have a following javascript function (in this function I want to know how to get the data from XML and use it instead of hardcoding )
function SetFaultAction(popupValue) {
// here the popupValue is the value selected in the textbox(according to my XML template its either 'Pending Fault found on' or 'Repaired Fault on')
var pendingFault = "Pending fault";
var repairedfault = "Already repaired";
if (popupValue.search(/Pending/i) > -1) {
document.getElementById('tbname').value = pendingFault;
}
else if (popupValue.search(/repaired/i)> -1){
document.getElementById('tbname').value = repairedfault;
}
the above javascript works fine. (But if I add two more text nodes under the fault element then the above javascript function will not work for those two newly added nodes). But what I want is, the values should be read from XML instead of hardcoding like popupValue.search(/Pending/i) > -1) and var pendingFault = "Pending fault";
Thanks,
Sachi
Reply
Answers (
1
)
ScriptManager' is ambiguous in the namespace 'System.Web.UI'
To remove Port Number in URL