How get a node whose title is separated by a colon? #119
-
I have little to no experience with <?xml version="1.0" encoding="UTF-8"?>
<feed xmlns:dcterms="http://purl.org/dc/terms/" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:app="http://www.w3.org/2007/app" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom" xmlns:opds="http://opds-spec.org/2010/catalog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en" xmlns:odl="http://opds-spec.org/odl" xmlns:schema="http://schema.org">
<id>https://catalog.feedbooks.com/publicdomain/browse/homepage_selection.atom</id>
<title>New & noteworthy</title>
<updated>2021-02-03T10:44:23Z</updated>
<icon>/favicon.ico</icon>
<author>
<name>Feedbooks</name>
<uri>http://www.feedbooks.com</uri>
<email>[email protected]</email>
</author>
<link rel="self" type="application/atom+xml;profile=opds-catalog;kind=acquisition; charset=utf-8" href="https://catalog.feedbooks.com/publicdomain/browse/homepage_selection.atom"/>
<link rel="start" type="application/atom+xml;profile=opds-catalog;kind=navigation" title="Home" href="https://catalog.feedbooks.com/catalog/index.atom"/>
<link rel="search" href="https://catalog.feedbooks.com/opensearch.xml" type="application/opensearchdescription+xml" title="Search on Feedbooks"/>
<link rel="http://opds-spec.org/shelf" type="application/atom+xml;profile=opds-catalog;kind=acquisition" title="Bookshelf" href="https://www.feedbooks.com/user/bookshelf.atom"/>
<opensearch:totalResults>0</opensearch:totalResults>
<opensearch:itemsPerPage>50</opensearch:itemsPerPage>
<opensearch:startIndex>1</opensearch:startIndex>
</feed> from which I need to get the values of : <opensearch:totalResults>0</opensearch:totalResults>
<opensearch:itemsPerPage>50</opensearch:itemsPerPage>
<opensearch:startIndex>1</opensearch:startIndex>
I tried doing like this: XmlElement totalResult = parsedXml.getElement('opensearch:totalResults');
String totalResultInString = totalResult.text;
But the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I guess XmlElement totalResult = parsedXml.rootElement.getElement('opensearch:totalResults'); |
Beta Was this translation helpful? Give feedback.
-
@renggli Thank you that worked :) |
Beta Was this translation helpful? Give feedback.
I guess
parsedXml
is the XmlDocument? If so, the elements of this node are the<?xml ...
and<feed xmlns ...
nodes, which obviously do not match the element name you are searching for. UseparsedXml.rootElement
to get the root element of your DOM tree (<feed xmlns ...
); then you can ask that one for the values you're after: