Can xml attributes contain an underscore?

D

DC

I'm having some non-success trying to parse an xml file containing
underscores in the attributes, like so:

<variables first_year="2000" lastyear="2006">
<variable var_name="cost" axis_name="year" type="entity"/>
<variable var_name="enrollment" axis_name="enroll" type="data"/>
<variable var_name="time" axis_name="time" type="data"/>
</variables>


The jquery call that I've used previously without success...something
like: alert ( $(this).attr("var_name"))...gives me a value of
undefined.
 
R

Richard Tobin

DC said:
I'm having some non-success trying to parse an xml file containing
underscores in the attributes, like so:

Underscores are legal. If they weren't, you'd get an error from the
parser, rather than an undefined value from a query.

-- Richard
 
Joined
Jul 24, 2008
Messages
2
Reaction score
0
non-success

If you had non-success without underscores, maybe have a look at your query? I use MS but I have have better times with some objects than others, for instance XMLDocument combined with XPath queries have worked for me, because as well as being able to use it in the code behind, JavaScript can call the ActiveX XML Dom object which is the same, but when I tried using XMLWriter I had some very strange errors. In the end, its just a parser, and there are so many that if one is giving you grief, there will be another to choose from. I'm sure its the same in the Java world.

Happy coding mate,
Henry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top