[jQuery] JQuery Xpath working?

2007-03-02 Thread Jeff Lawson
Hi,

I'm having trouble getting xpath selectors to work well, particularly  
on XML responses from ajax requests, using FF.  Hoping somebody can  
help.  Here are the steps I'm taking:

1.  Perform an ajax request using Prototype's Ajax.request, with an  
onComplete callback to my function.  Here's a sample response:

?xml version=1.0?
XMLResponse
   Errors/
   Warnings/
   Messages/
   Response
 ProductType
   Id40/Id
   NameChain/Name
   ProductGroupBMX/ProductGroup
   Margin/
   Properties
 PropertyTemplate
   Sid44c0ade1561d3/Sid
   ProductTypeId40/ProductTypeId
   PropertyTypeId34/PropertyTypeId
   PropertyType/
   Required0/Required
   NameWeight/Name
   Type1/Type
 /PropertyTemplate
   /Properties
/ProductType
   /Response
/XMLResponse


2.  In my function, calling jQuery(//ProductType/Properties/ 
PropertyTemplate) on the responseXML property of the response.   I  
get zero elements.

3.  Replacing the jquery with a css-style selector, works:  jQuery 
(ProductType Properties PropertyTemplate) returns 1 element.

I'd prefer to use xpath over css.  Any thoughts?  Thanks!

-jeff

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] Xpath and tab selection

2006-11-02 Thread radius

So I have a tabbed navigation system, and I am using jquery to
auto-select the current tab.
Here's the html:


ul id=main_nav
  li /services/ SERVICES /li
  li /store/ STORE /li
  li /about-us/ ABOUT US /li
  li /gallery/ GALLERY /li
  li /press/ PRESS /li
/ul


Here's my jQuery code (adapted from
http://leftlogic.com/info/articles?id=1):


if (location.pathname.substring(1)) {
   $('#main_nav [EMAIL PROTECTED]' + location.pathname.substring(1) +
']').parent().attr('id', 'current');
}

I'm using parent() so that the id gets applied to the 'li' element and
not the 'a' element.

All of this works. However, I'm unclear about a couple of things:

First, why is the dollar sign $ necessary in the xpath statement? i've
seen no documentation on it, and when i try it without the dollar sign,
it doesnt work.

Second, Sometimes I have a url like: /about-us/4/3 and my jQuery
statement fails because the href != location.pathname.
How can i rewrite this statement so that it searches for the href value
in the location.pathname value and applies the id to the matching
string?

Thanks in advance,
dd
-- 
View this message in context: 
http://www.nabble.com/Xpath-and-tab-selection-tf2563069.html#a7143657
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Xpath and tab selection

2006-11-02 Thread Brian Miller
Darius,

$= means attribute ends with.  Check out
http://jquery.com/docs/Base/Expression/CSS/ , the Supported, but
different section.

Taking a close look at the selection documentation might also help you
with item #2 a bit.

You're going to have to figure out how to text-match your relative URL
with the absolute URL that will be in location.pathname using plain old
regular expressions.

Keep in mind that IE automatically converts relative URLs to absolute ones
in memory, while the other browsers don't.  This may affect your results.

- Brian


 So I have a tabbed navigation system, and I am using jquery to
 auto-select the current tab.
 Here's the html:


 ul id=main_nav
   li /services/ SERVICES /li
   li /store/ STORE /li
   li /about-us/ ABOUT US /li
   li /gallery/ GALLERY /li
   li /press/ PRESS /li
 /ul


 Here's my jQuery code (adapted from
 http://leftlogic.com/info/articles?id=1):


 if (location.pathname.substring(1)) {
$('#main_nav [EMAIL PROTECTED]' + location.pathname.substring(1) +
 ']').parent().attr('id', 'current');
 }

 I'm using parent() so that the id gets applied to the 'li' element and
 not the 'a' element.

 All of this works. However, I'm unclear about a couple of things:

 First, why is the dollar sign $ necessary in the xpath statement? i've
 seen no documentation on it, and when i try it without the dollar sign,
 it doesnt work.

 Second, Sometimes I have a url like: /about-us/4/3 and my jQuery
 statement fails because the href != location.pathname.
 How can i rewrite this statement so that it searches for the href value
 in the location.pathname value and applies the id to the matching
 string?

 Thanks in advance,
 dd
 --
 View this message in context:
 http://www.nabble.com/Xpath-and-tab-selection-tf2563069.html#a7143657
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/




___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Xpath and tab selection

2006-11-02 Thread radius

Thanks a bunch for that link, Brian. I really did search the documentation,
and I feel crazy for missing that rather obvious link from the XPath
section.

I ended up going the less-than-elegant route and breaking out of jQuery to
use the JS match() function, but it works nicely:

if (location.pathname.substring(1)) {
$('#main_nav').find('a').each(
function() {
if(location.pathname.match( $(this).attr('href') ) )
$(this).parent().attr('id', 'current');

});
}


Cheers!

dd


Citrus wrote:
 
 Darius,
 
 $= means attribute ends with.  Check out
 http://jquery.com/docs/Base/Expression/CSS/ , the Supported, but
 different section.
 
 Taking a close look at the selection documentation might also help you
 with item #2 a bit.
 
 You're going to have to figure out how to text-match your relative URL
 with the absolute URL that will be in location.pathname using plain old
 regular expressions.
 
 Keep in mind that IE automatically converts relative URLs to absolute ones
 in memory, while the other browsers don't.  This may affect your results.
 
 - Brian
 
 
 So I have a tabbed navigation system, and I am using jquery to
 auto-select the current tab.
 Here's the html:


 ul id=main_nav
   li /services/ SERVICES /li
   li /store/ STORE /li
   li /about-us/ ABOUT US /li
   li /gallery/ GALLERY /li
   li /press/ PRESS /li
 /ul


 Here's my jQuery code (adapted from
 http://leftlogic.com/info/articles?id=1):


 if (location.pathname.substring(1)) {
$('#main_nav [EMAIL PROTECTED]' + location.pathname.substring(1) +
 ']').parent().attr('id', 'current');
 }

 I'm using parent() so that the id gets applied to the 'li' element and
 not the 'a' element.

 All of this works. However, I'm unclear about a couple of things:

 First, why is the dollar sign $ necessary in the xpath statement? i've
 seen no documentation on it, and when i try it without the dollar sign,
 it doesnt work.

 Second, Sometimes I have a url like: /about-us/4/3 and my jQuery
 statement fails because the href != location.pathname.
 How can i rewrite this statement so that it searches for the href value
 in the location.pathname value and applies the id to the matching
 string?

 Thanks in advance,
 dd
 --
 View this message in context:
 http://www.nabble.com/Xpath-and-tab-selection-tf2563069.html#a7143657
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/

 
 
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/Xpath-and-tab-selection-tf2563069.html#a7145094
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath query whoas/bugs?

2006-10-15 Thread Jörn Zaefferer
Stephen Woodbridge schrieb:
 John,

 Thank you for looking at this. Removing the '//' helps a little. Now 
 both the alerts work in FF, and in IE6 it no longer throws an error, but 
 both of the searches in IE6 appear to return a null string (ie: '')

 Also changing the first alert to:

 alert(' + 
 $('/html/body/xml/[EMAIL PROTECTED]country]/[EMAIL 
 PROTECTED]NAME]').text() 
 + ');

 works on FF but throws an error on IE6. This might be a clue about what 
 is going on.
   
#164 is not yet resolved, see my latest comment there. 
http://jquery.com/dev/bugs/bug/164/
IE reacts really weird when using getAttribute on an XML element. Looks 
like we need some more workarounds.

-- Jörn

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath query whoas/bugs?

2006-10-15 Thread John Resig
Jörn -

 #164 is not yet resolved, see my latest comment there.
 http://jquery.com/dev/bugs/bug/164/
 IE reacts really weird when using getAttribute on an XML element. Looks
 like we need some more workarounds.

That code has already been changed in SVN. Please make sure that
you're current. I think we should fix a couple more bugs then just
push out 1.0.3 very soon.

--John

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath query whoas/bugs?

2006-10-15 Thread Stephen Woodbridge
John Resig wrote:
 Jörn -
 
 #164 is not yet resolved, see my latest comment there.
 http://jquery.com/dev/bugs/bug/164/
 IE reacts really weird when using getAttribute on an XML element. Looks
 like we need some more workarounds.
 
 That code has already been changed in SVN. Please make sure that
 you're current. I think we should fix a couple more bugs then just
 push out 1.0.3 very soon.

Just grabbed svn and $(document).ready(function(){alert(hello)}); does 
not fire on IE.

http://imaptools.com:8081/maps/test2.html

-Steve

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath query whoas/bugs?

2006-10-15 Thread Stephen Woodbridge
John Resig wrote:
 Just grabbed svn and $(document).ready(function(){alert(hello)}); does
 not fire on IE.
 
 Sorry about that, it's now fixed in SVN rev 442.

NP, thanks for the updates.

OK, this is good in FF, in IE6 no errors, but returns a '' for the xpath 
queries instead of the correct results.

This is a simple self contained test page except for including jquery.js
http://imaptools.com:8081/maps/test2.html

-Steve

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath query whoas/bugs?

2006-10-14 Thread John Resig
Stephen -

After doing some testing, it seems as if the culprit is the '//' that
you have in front of your expression. It's perfectly ok to remove it -
as it will continue to work correctly.

It seems to be that if you do .find(//foo) or $(//foo, context) it
freaks out. But this is ok, since doing that is completely redundant
in jQuery. Just remove the // to make it .find(foo) or $(foo,
context) and you'll be fine.

I'm still not entirely sure /why/ this happens - but it does. Here's
the ticket for it:
http://jquery.com/dev/bugs/bug/281/

Does changing this fix the problems that you were having related to bug #164?

--John

On 10/14/06, Stephen Woodbridge [EMAIL PROTECTED] wrote:
 Hi all,

 I am trying to figure out xpath queries, but I am missing something
 and/or running into bugs. John pointed me at Bug #164, which has been
 closed, but I still have problems. Here is a simple script with two
 alerts. Each alert should report United States from the embedded xml.

 o The 1st alert works on on FF but not IE6
 o The 2nd alert does not work on either

 Are these bugs?
 Do I need to open a bug on these?
 Am I doing this wrong?

 Thanks,
-Steve

 Here is a url to test it:
http://imaptools.com:8081/maps/test2.html

 Here is source:
 html xmlns=http://www.w3.org/1999/xhtml; lang=en xml:lang=en
 head
 script type=text/javascript src=/js/jquery.js/script
 script type=text/javascript

  $(document).ready(function(){

  // get the xml data island
  var xml = $(#aaa);

 // this searches the dom and works in FF but not IE 6
 alert( $('//[EMAIL PROTECTED]country]/[EMAIL PROTECTED]NAME]'
 ).text());

 // this should search using the xml variable as context
 // this does not work in either FF or IE6
 alert( $('//[EMAIL PROTECTED]country]/[EMAIL PROTECTED]NAME]',
 xml ).text());

  });
 /script

 /head
 body

 xml id=aaa style=display: none;
point srsName=geographic
  coordinates
-71.385697,42.636016
  /coordinates
/point
feature typeName=country
  description
Country
  /description
  property typeName=NAME
United States
  /property
  property typeName=CAPITAL
Washington DC
  /property
  property typeName=CONTINENT
North America
  /property
  property typeName=DISTANCE_TO_POINT typeUnits=feet
0
  /property
/feature
 /xml

 /body
 /html

 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/



-- 
John Resig
http://ejohn.org/
[EMAIL PROTECTED]

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath query whoas/bugs?

2006-10-14 Thread Stephen Woodbridge
John,

Thank you for looking at this. Removing the '//' helps a little. Now 
both the alerts work in FF, and in IE6 it no longer throws an error, but 
both of the searches in IE6 appear to return a null string (ie: '')

Also changing the first alert to:

alert(' + 
$('/html/body/xml/[EMAIL PROTECTED]country]/[EMAIL PROTECTED]NAME]').text() 
+ ');

works on FF but throws an error on IE6. This might be a clue about what 
is going on.

-Steve

John Resig wrote:
 Stephen -
 
 After doing some testing, it seems as if the culprit is the '//' that
 you have in front of your expression. It's perfectly ok to remove it -
 as it will continue to work correctly.
 
 It seems to be that if you do .find(//foo) or $(//foo, context) it
 freaks out. But this is ok, since doing that is completely redundant
 in jQuery. Just remove the // to make it .find(foo) or $(foo,
 context) and you'll be fine.
 
 I'm still not entirely sure /why/ this happens - but it does. Here's
 the ticket for it:
 http://jquery.com/dev/bugs/bug/281/
 
 Does changing this fix the problems that you were having related to bug #164?
 
 --John
 
 On 10/14/06, Stephen Woodbridge [EMAIL PROTECTED] wrote:
 Hi all,

 I am trying to figure out xpath queries, but I am missing something
 and/or running into bugs. John pointed me at Bug #164, which has been
 closed, but I still have problems. Here is a simple script with two
 alerts. Each alert should report United States from the embedded xml.

 o The 1st alert works on on FF but not IE6
 o The 2nd alert does not work on either

 Are these bugs?
 Do I need to open a bug on these?
 Am I doing this wrong?

 Thanks,
-Steve

 Here is a url to test it:
http://imaptools.com:8081/maps/test2.html

 Here is source:
 html xmlns=http://www.w3.org/1999/xhtml; lang=en xml:lang=en
 head
 script type=text/javascript src=/js/jquery.js/script
 script type=text/javascript

  $(document).ready(function(){

  // get the xml data island
  var xml = $(#aaa);

 // this searches the dom and works in FF but not IE 6
 alert( $('//[EMAIL PROTECTED]country]/[EMAIL PROTECTED]NAME]'
 ).text());

 // this should search using the xml variable as context
 // this does not work in either FF or IE6
 alert( $('//[EMAIL PROTECTED]country]/[EMAIL PROTECTED]NAME]',
 xml ).text());

  });
 /script

 /head
 body

 xml id=aaa style=display: none;
point srsName=geographic
  coordinates
-71.385697,42.636016
  /coordinates
/point
feature typeName=country
  description
Country
  /description
  property typeName=NAME
United States
  /property
  property typeName=CAPITAL
Washington DC
  /property
  property typeName=CONTINENT
North America
  /property
  property typeName=DISTANCE_TO_POINT typeUnits=feet
0
  /property
/feature
 /xml

 /body
 /html

 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/

 
 


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] XPath expressions not working

2006-10-03 Thread Raziel Alvarez
I've been testing and I see many really simple XPath queries that just don't work, or they even break.

Is this broken in jQuery? Are they working for somebody?

thanks

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath expressions not working

2006-10-03 Thread Jörn Zaefferer
Raziel Alvarez schrieb:
 I've been testing and I see many really simple XPath queries that just 
 don't work, or they even break.
  
 Is this broken in jQuery? Are they working for somebody?
jQuery does not claim to implement the XPath standard. It just supports 
a small subset, and these should work. Could you provide more specific 
examples that don't work?

-- Jörn

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath expressions not working

2006-10-03 Thread Raziel Alvarez
I sent an email yesterday, but maybe it didn't got through. 

Anyway, this is it:

I have this simple markup:

componentDom.innerHTML = 

form action=""> h1 name=formTitle/h1 p name=formInstructions/p div name=top /div div name=formContent 
divname=columndiv /div/div /div div name=bottom input type=submit name=defaultButton value=Submit/ 
 /div/form

I'm executing this xpath calls with the following results:

$('form/[EMAIL PROTECTED]', componentDom).length = 3
$('form/[EMAIL PROTECTED]', componentDom)[0].innerHTML =
$('form/[EMAIL PROTECTED]', componentDom)[1].innerHTML= DIV name=\column\DIV/DIV/DIV
$('form/[EMAIL PROTECTED]', componentDom)[2].innerHTMLINPUT type=submit value=Submit name=defaultButton 
$('form/[EMAIL PROTECTED]/input', componentDom)Object requiredError
$('//div', componentDom)'undefined' is null or not an objectError
$('form//div', componentDom).length= 6

$('form//div/input', componentDom).length= Object requiredError


I don't understand why it's failing. I'm just asking for the input which it's obviously there, under the last DIV. Like this, I've come across many really simple XPath queries that just don't work. Am I doing something wrong? Is it XPath actually supported? 


Moreover:

Thos queries that return an error, like: 

$('form//div/input', componentDom);

break in the siblingfunction(elem, pos, not) since elem is null. Probably this is related to the bug where children() breaks when there are no children.

I know jQuery doesn't support the full XPath standard but as you can see my expressions are really simple, andanyway it shouldn't break.

Thanks

On 10/3/06, Jörn Zaefferer [EMAIL PROTECTED] wrote: 

Raziel Alvarez schrieb: I've been testing and I see many really simple XPath queries that just
 don't work, or they even break. Is this broken in jQuery? Are they working for somebody?jQuery does not claim to implement the XPath standard. It just supportsa small subset, and these should work. Could you provide more specific 
examples that don't work?-- Jörn___jQuery mailing list
discuss@jquery.comhttp://jquery.com/discuss/
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] XPath Axes: ancestor(-or-self) / parents / descendent / children

2006-09-25 Thread George Adamson

I'm interested to know how to extend the selector syntax to accept things
like axis definitions etc. (I know from the forum that we should be using
the .parents() methods etc but I'd like to extend the selector syntax
myself.)

While the .parent() and .children() methods etc work very well when combined
with the excellent XPath-style selector support, I'm finding many situations
where axis selectors such as ancestor:: and ancestor-or-self:: etc (or a
shorthand) would be very useful in the selector expression itself as an
alternative. (Note: The // syntax is already a good way to do some
descendent:: like functionality.)

I'm gradually building up a simple 'selectors' plugin to add selectors that
are not in the core. Another kind member has already explained how to add to
the :expr selectors so I have already developed :focus and :hover, with more
on their way (such as those in the docs pages that are not actually in the
current jquery release).

Please note that I'm not trying to restart this debate, I'm just after info
on the best way to provide axis filters in the expression strings. Adding to
the :expr is easy enough because they just need to return true or false. I
just can't figure out how to enable axis:: selectors.

Many thanks,
George Adamson
-- 
View this message in context: 
http://www.nabble.com/XPath-Axes%3A-ancestor%28-or-self%29---parents---descendent---children-tf2331493.html#a6486088
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath '[EMAIL PROTECTED]' doesn't work on XML documents

2006-09-11 Thread Mark Gibson
Mark Gibson wrote:
 John Resig wrote:
 Just a hunch, but IE's DOM support isn't native Javascript. If they got
 their typelib wrong it may be trying to call getAttribute rather than check
 elem for a getAttribute property. Can you replace that last line with this
 and see if it works?

 } else if ( typeof(elem.getAttribute) != undefined ) {
 
 Ok, this fixes one problem, but a further error occurs on line 641:
 
   return elem.getAttribute( name, 2 );
 
 It appears that the getAttribute method on XML elements only accepts
 a single argument:
 
   return elem.getAttribute( name );
 
  From the MS docs the second argument of 2 forces the method to be
 case-sensitive, which if I'm correct, isn't required by any browser
 other than IE. So is it possible to detect whether the browser is IE
 and the document is an HTML doc - in which case use the two args method,
 otherwise call with just one arg.

Sorry, I got this wrong - it doesn't force case sensitive.

According to the docs:
2 - Returns the value exactly as it was set in script or in the source 
document.

Now I'm even more confused, what else would it return?

- Mark.

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] XPath '[EMAIL PROTECTED]' doesn't work on XML documents

2006-09-08 Thread Mark Gibson

Hello,
I've come across a strange bug in IE:

I've loaded an XML doc using $.get(), and
selecting nodes using an XPath with a predicate
containing an attribute: $([EMAIL PROTECTED], xml)

IE just throws a wobbly:

   Line: 639
   Error: Wrong number of arguments or invalid property assignment

which appears to reside in the 'attr' function, the line is:

} else if ( elem.getAttribute ) {

as you see the message is a bit vague, i don't see a function
call here or an attempt at assigning a property!

I've attached demonstration files html/js/xml.
(.js renamed to .jsx - as the mail server rejected it!!!)

BTW, this works fine in Firefox, what a surprise! ;)

Cheers
- Mark Gibson

(jQuery: r249)
(IE: 6)

Title: jQuery Testing




	Test
	Your
	Mum


test
	data stuff=0/
	data stuff=1/
/test

$(function() {

alert($([EMAIL PROTECTED]).length); // This works (shows: 2)

$.get(selector.xml, function(xml) {
alert($([EMAIL PROTECTED], xml).length); // This fails in IE
});

});
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath '[EMAIL PROTECTED]' doesn't work on XML documents

2006-09-08 Thread Ian B

Mark
Yes - I flagged this up a few days ago 
http://www.nabble.com/Searching-for-XML-attribute-tf2215205.html Link Here 
Still waiting for resolution - don't know if I need to raise a bug report...
Ian



Mark Gibson-8 wrote:
 
 Hello,
 I've come across a strange bug in IE:
 
 I've loaded an XML doc using $.get(), and
 selecting nodes using an XPath with a predicate
 containing an attribute: $([EMAIL PROTECTED], xml)
 
 IE just throws a wobbly:
 
 Line: 639
 Error: Wrong number of arguments or invalid property assignment
 
 which appears to reside in the 'attr' function, the line is:
 
   } else if ( elem.getAttribute ) {
 
 as you see the message is a bit vague, i don't see a function
 call here or an attempt at assigning a property!
 
 I've attached demonstration files html/js/xml.
 (.js renamed to .jsx - as the mail server rejected it!!!)
 
 BTW, this works fine in Firefox, what a surprise! ;)
 
 Cheers
 - Mark Gibson
 
 (jQuery: r249)
 (IE: 6)
 
 
 
 
 
   jQuery Testing
   
   
 
 
   Test
   Your 
   Mum 
 
 
 
 test
   data stuff=0/
   data stuff=1/
 /test
 
 
 $(function() {
 
   alert($([EMAIL PROTECTED]).length); // This works (shows: 2)
 
   $.get(selector.xml, function(xml) {
   alert($([EMAIL PROTECTED], xml).length); // This fails in IE
   });
 
 });
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/XPath-%27tag-%40att-%27-doesn%27t-work-on-XML-documents-tf2239741.html#a6211228
Sent from the JQuery forum at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath '[EMAIL PROTECTED]' doesn't work on XML documents

2006-09-08 Thread Dave Methvin
 
 IE just throws a wobbly:
 
 Line: 639
 Error: Wrong number of arguments or invalid property assignment
 
 which appears to reside in the 'attr' function, the line is:
 
   } else if ( elem.getAttribute ) {

Just a hunch, but IE's DOM support isn't native Javascript. If they got
their typelib wrong it may be trying to call getAttribute rather than check
elem for a getAttribute property. Can you replace that last line with this
and see if it works?

} else if ( typeof(elem.getAttribute) != undefined ) {


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath '[EMAIL PROTECTED]' doesn't work on XML documents

2006-09-08 Thread John Resig
 Just a hunch, but IE's DOM support isn't native Javascript. If they got
 their typelib wrong it may be trying to call getAttribute rather than check
 elem for a getAttribute property. Can you replace that last line with this
 and see if it works?

 } else if ( typeof(elem.getAttribute) != undefined ) {

I just committed this to SVN.

--John

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] xPath

2006-09-03 Thread Sam
Newbie question:

Can I use jQuery's xPath capability to locate an element in an arbitrary XML 
file loaded using Ajax?

Sam





___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] xPath

2006-09-03 Thread Christof Donat
Hi,

 Can I use jQuery's xPath capability to locate an element in an arbitrary
 XML file loaded using Ajax?

Yes:

$('/my/[EMAIL PROTECTED]',XMLDOMDocument)

Christof

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] xPath

2006-09-03 Thread John Resig
 Can I use jQuery's xPath capability to locate an element in an arbitrary XML 
 file loaded using Ajax?

Yes! For example:

$.post(test.xml,function(data){
  $(//foo/bar,data).each( ... );

  // or, with CSS:

  $(foo  bar).each( ... );
});

It's important to note that jQuery only supports a very very small
subset of the full XPath spec. More details here:
http://proj.jquery.com/docs/Base/Expression/XPath/

--John

--John

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath

2006-08-15 Thread Fil

I want the expression to verify that the link is in the correct data
structure, i.e. inside a dt that is inside a dl and where
$(this).parent().next() is a dd.

Said differently: I want to tell my script if the link is inside a dt
then show() the corresponding dd (if it exists).

That's why I was trying to use XPath and the parent::x syntax (and failed
miserably, ha ha).


 In the SVN build of jQuery you can do:
 
 $(this).parent().next().show();
 
 jQuery SVN can be found here:
 http://jquery.com/src/jquery-svn.js
 
 --John
 
  I have the following structure:
 
 dl
  dta href=urlx/a/dt
  ddtext/dd
 /dl
 
 
  I select the a element in this, and I want to show() the corresponding dd.
 
 
  This works but is not very precise:
  $(../../dt/../dd, this).show();
 
  I'm trying to write it more precisely with something like:
  $(parent::dt/parent::dl/dd, this).show();
 
  but I'm not finding the correct expression...

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath

2006-08-15 Thread kenton.simpson

$(dl dt a).click(function (event) {
  event.preventDefault();
  event.stopPropagation();
  $(this).parent().next().show(); 
}); 


Fil wrote:
 
 
 I want the expression to verify that the link is in the correct data
 structure, i.e. inside a dt that is inside a dl and where
 $(this).parent().next() is a dd.
 
 Said differently: I want to tell my script if the link is inside a dt
 then show() the corresponding dd (if it exists).
 
 That's why I was trying to use XPath and the parent::x syntax (and failed
 miserably, ha ha).
 
 
 In the SVN build of jQuery you can do:
 
 $(this).parent().next().show();
 
 jQuery SVN can be found here:
 http://jquery.com/src/jquery-svn.js
 
 --John
 
  I have the following structure:
 
 dl
  dt url x /dt
  ddtext/dd
 /dl
 
 
  I select the   element in this, and I want to show() the corresponding
 dd.
 
 
  This works but is not very precise:
  $(../../dt/../dd, this).show();
 
  I'm trying to write it more precisely with something like:
  $(parent::dt/parent::dl/dd, this).show();
 
  but I'm not finding the correct expression...
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/XPath-tf2106968.html#a5813465
Sent from the JQuery forum at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] XPath

2006-08-14 Thread John Resig
In the SVN build of jQuery you can do:

$(this).parent().next().show();

jQuery SVN can be found here:
http://jquery.com/src/jquery-svn.js

--John

 I have the following structure:

dl
 dta href=urlx/a/dt
 ddtext/dd
/dl


 I select the a element in this, and I want to show() the corresponding dd.


 This works but is not very precise:
 $(../../dt/../dd, this).show();

 I'm trying to write it more precisely with something like:
 $(parent::dt/parent::dl/dd, this).show();

 but I'm not finding the correct expression...

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/