Guest clesueur Posted December 7, 2007 Share Posted December 7, 2007 Trying to get my head round xml and xpath but ive tried tutorials with no luck so far.. on "http://blog.opject.org/?page_id=4#Conclusion" the tutorial says i just need the code below for the titles to be traced to the output box but ive done this and i get no output at all!Ive updated XFactorstudio’s XPath files but still nothing happens in the output box!Can anyone help?! am i missing something here? im getting totally lost with this now as i cant get things to work. Thank you... (code and xml info below)import mx.xpath.XPathAPI;var books : XML;books = new XML();books.ignoreWhite = true;books.onLoad = function(success : Boolean) : Void{var titles : Array;titles = XPathAPI.selectNodeList(books.firstChild, "/books/*/title/*");trace( titles );};books.load("books.xml");xml file:<?xml version="1.0" encoding="UTF-8" ?><books><book id='0'><author>J.R.R. Tolkien</author><title>The Lord of the Rings</title><isbn>0618346252</isbn><price>34.95</price></book><book id='1'><author>Dan Brown</author><title>The Da Vinci Code<title><isbn>1400079179</isbn><price>17.95</price></book></books> Link to comment Share on other sites More sharing options...
boen_robot Posted December 8, 2007 Share Posted December 8, 2007 "title" doesn't have any child elements. With the part "title/*", you're telling XPath to get the value of the first child element of "title", regardless of its name. But there's no such element, and thus XPath returns nothing.Use the expression: "/books/*/title" instead. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.