473,386 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Read XML string attributes with Javascript

26
I have a XML string returned from SQL server as a result of select query. The XML string looks like:

Expand|Select|Wrap|Line Numbers
  1. <row col1="value1", col2="value2"/><row col1="value12", col2="value22"/>
At the client side I want to read a specific row based on the user selected value.

For example, if the user selects a drop down item whose value is "value1" I want to read the col2 value from the xml string where the col1 value is "value1". How can I achieve this? It seems doable, but being a n00b in web programming I'm unable to get hold of this thing.

Thanks.
Apr 28 '08 #1
4 2364
vee10
141 100+
This link may help u

http://www.codeproject.com/KB/scripting/xmljs.aspx



I have a XML string returned from SQL server as a result of select query. The XML string looks like:

<row col1="value1", col2="value2"/><row col1="value12", col2="value22"/>

At the client side I want to read a specific row based on the user selected value.

For example, if the user selects a drop down item whose value is "value1" I want to read the col2 value from the xml string where the col1 value is "value1". How can I achieve this? It seems doable, but being a n00b in web programming I'm unable to get hold of this thing.

Thanks.
Apr 28 '08 #2
acoder
16,027 Expert Mod 8TB
This link may help u

http://www.codeproject.com/KB/scripting/xmljs.aspx
Ugh! IE-only :(

Try something cross-browser instead. See how you can access nodes.
Apr 28 '08 #3
rjvrnjn
26
Hmmm... I'd been through those articles. On looking through the code more I realised that my XML was not well formed. The root element was missing (as the XML code emited by SQL server didn't have the root node). I modified the XML string to enclose it between <root></root> (it could have been anything else). And wow that worked.

Thanks guys for your time.
Apr 29 '08 #4
acoder
16,027 Expert Mod 8TB
Seeing as you said you were new to all this, I thought a good tutorial would help, not to mention the fact that I hate IE-only tutorials when there's a clear alternative for other browsers.

Anyway, glad that you've fixed it. That is one of the first things to check.
Apr 29 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tom | last post by:
I'm trying to find a good, solid function that sanitizes string values for form validation. The user notes on php.net offer the following: ...
21
by: Gavin | last post by:
Hi, I'm a newbie to programming of any kind. I have posted this to other groups in a hope to get a response from anyone. Can any one tell me how to make my VB program read the Bios serial number...
2
by: Martin Huber | last post by:
Hello Newsgroup, I want to make a javascript application, that reads out the directorys on my hard disk and show in a checkbox if a folder is read- or writeable. So I can change attributes on an...
2
by: Raghu Gupta | last post by:
Hi, Actually i am facing some problem using quickbooks and presently i am not so expert in using it. I am using c# code to retrive the data from quickbooks. it doesn't matter which language we...
1
by: Chua Wen Ching | last post by:
Hi there, I have some problems when reading XML file. 1. First this, is what i did, cause i can't seem to read "sub elements or tags" values, so i place those values into attributes like this....
10
by: Andrew | last post by:
Hi ALL, I have a javascript code which i register using page.RegisterClientScriptBlock() in my btnFinish() button_click event. I noticed that the debugger will run thru the whole event for my...
4
by: simon | last post by:
hi, I would like to separate my javascript completely from my xhtml. in the end there should be only <script type="text/javascript" src="javalib.js"></script> in the head-tag to my javascript....
6
by: | last post by:
Hi, I'm steel trying to read and update my XML file with Visual Basic Express but i am unable to find the right way to read my xml file and update it if neccessary... Here is my problem :...
3
hemantbasva
by: hemantbasva | last post by:
i have written a the following javascript code to copy data onto clipboard but i am getting error Unterminated string constant code in cs file if (lblProcedureID != null) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.