Skip to main content

response_text

Function response_text 

Source
pub fn response_text(xml: &str, name: &str) -> Option<String>
Expand description

Read the text content of a named argument out of a SOAP response body.

UPnP action responses are flat: every out-argument is a leaf element directly under <{action}Response>, which is itself under <Body>. Rather than build a DOM, this walks the document once with quick-xml and returns the text of the first element whose local name matches name, so namespace prefixes (u:CurrentVolume) match unprefixed lookups. Text split across several nodes is concatenated, and entities are decoded.

Returns None when the element is absent, and Some("") when it is present but empty — the same distinction xmltree’s get_child(..).get_text() drew, except that get_text() also returned None for a childless element. Callers here all funnel through unwrap_or_default()/parse().ok(), so the two are equivalent downstream.