1

I have an XML document that looks someting like this:

<event>
    <foo.bar>content</foo.bar>
</event>

I use jQuery to read this xml document as follows:

var $xml = $( $.parseXML(xmlStr) );

When i try to select the foo.bar node, it will search for a node with the name foo and the class bar. How can i select this node by tagname?

$xml.find( "foo.bar" ) //returns nothing, searches for tag foo with class bar
oogie
  • 27
  • 4

2 Answers2

5

You need to escape the . in the selector:

$xml.find("foo\\.bar")
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
2

You could try to use this:

$xml.find( "foo\\.bar" )

You need an escape character for the ..

Christos
  • 53,228
  • 8
  • 76
  • 108