0

after reading jquery xml select I wanted to do something similar with this rdf/xml:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
 <rdf:Description rdf:about="http://someURI/999">
  <dc:relation rdf:resource="http://www.someURI/888" />
 </rdf:Description>
 <rdf:Description rdf:about="http://www.someURI/001">
  <dc:relation rdf:resource="http://www.someURI/987/777"/>
 </rdf:Description>
</rdf:RDF>

I want to select the node with the attribute "rdf:about" ending with 001. I tried:

var node = $(xml).find("rdf:Description[rdf:about$=001]");

But it wont work. It returns the whole thing document. Any ideas?

Edit: Corrected spelling error. Doesn't change the problem, though.

3 Answers 3

1

Uhm... I think is an escape problem. Try to use

var node = $(xml).find("rdf\\:Description[rdf\\:about$=001]");
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry tanathos, I have been working on this (way to long). I really don't understand why this doesn't work for me. The longer I stare at it, the more I am convinced that it is correct and my error has to be somewhere else. I'll keep looking and use a workaround for now. Thanks for your help- sorry for the late accept.
0

Check your spelling. It's rdf:Description with an upper-case D. In XML, the case is significant.

2 Comments

Yes and no. There is a spelling error, but once corrected I still see the same behavior. Which made me thinking: Is my handling of the return value incorrect? I do that like so: var node = $(rdfDoc).find("rdf:Description[rdf:about$=001]");
tanathos got it right, as far as I can see. The colon must be escaped. There's nothing wrong with the variable assignment, it's best jQuery style ;-)
0

Run into similar problem. For me dropping the namespace worked.
So I would try something like: $(rdfDoc).find("Description[about$=001]"); Not 100% sure about the attribute cause I was only trying to obtain node.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.