parse xml to work with xpath through javascript



I'm trying to use xpath to parse a google book search result, but I am running into some 2 problems. First, I am getting an error The default (no prefix) Namespace URI for XPath queries is always '' and it cannot be redefined to... Second, I get an error about prefixes when parsing. Since I'm using JS to evaluate the xpath expressions, I decided the easiest way will be to edit the xml file prior to parsing. I can easily remove the prefixes using replace, but I am having trouble removing all the feed attributes. I'd like to change <feed xmlns="http://ift.tt/r5ut6F"...> to just <feed>. Thoughts?



<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://ift.tt/r5ut6F" xmlns:batch="http://ift.tt/1fDpyew" xmlns:dc="http://ift.tt/1jGKdy3" xmlns:gbs="http://ift.tt/145SVUM" xmlns:gd="http://ift.tt/17PKlnd" xmlns:openSearch="http://ift.tt/13zUF5b">
<id>http://ift.tt/1Aq01A2;
<updated>2015-01-03T16:32:48.000Z</updated>
<category scheme="http://ift.tt/qkaDoc" term="http://ift.tt/145SWb8" />
<title type="text">Search results for isbn:190499458X</title>
<link rel="alternate" type="text/html" href="http://www.google.com" />
<link rel="http://ift.tt/13zUF5c" type="application/atom+xml" href="http://ift.tt/1Aq00fC" />
<link rel="self" type="application/atom+xml" href="http://ift.tt/1Aq00fE" />
<author>
<name>Google Books Search</name>
<uri>http://ift.tt/145SWYJ;
</author>
<generator version="beta">Google Book Search data API</generator>
<openSearch:totalResults>1</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>1</openSearch:itemsPerPage>
<entry>
<id>http://ift.tt/1Aq00vY;
<updated>2015-01-03T16:32:48.000Z</updated>
<category scheme="http://ift.tt/qkaDoc" term="http://ift.tt/145SWb8" />
<title type="text">Guinness World Records 2011</title>
<link rel="http://ift.tt/145SWYP" type="image/x-unknown" href="http://ift.tt/1Aq00w6" />
<link rel="http://ift.tt/1Aq00Mo" type="text/html" href="http://ift.tt/1Aq00Mq" />
<link rel="http://ift.tt/1Aq00Mu" type="text/html" href="http://ift.tt/145SZ6I" />
<link rel="http://ift.tt/1Aq00My" type="application/atom+xml" href="http://ift.tt/145SZ6O" />
<link rel="alternate" type="text/html" href="http://ift.tt/145SXff" />
<link rel="self" type="application/atom+xml" href="http://ift.tt/1Aq01QB" />
<gbs:contentVersion>preview-1.0.0</gbs:contentVersion>
<gbs:embeddability value="http://ift.tt/145SZ6Q" />
<gbs:openAccess value="http://ift.tt/1Aq01QG" />
<gbs:viewability value="http://ift.tt/145SYQo" />
<dc:creator>Guinness World Records</dc:creator>
<dc:date>2010</dc:date>
<dc:description>Lists records, superlatives, and unusual facts in the areas of fame, business, crime, the natural world, technology, war, the arts, music, fashion, and sports.</dc:description>
<dc:format>287 pages</dc:format>
<dc:format>book</dc:format>
<dc:identifier>bLlrRQAACAAJ</dc:identifier>
<dc:identifier>ISBN:190499458X</dc:identifier>
<dc:identifier>ISBN:9781904994589</dc:identifier>
<dc:language>en</dc:language>
<dc:publisher>Guinness World Records Limited</dc:publisher>
<dc:subject>Reference</dc:subject>
<dc:title>Guinness World Records 2011</dc:title>
</entry>
</feed>

No comments:

Post a Comment