Skip to content

Commit 0775c74

Browse files
committed
ignore empty optional tag when get text
1 parent 27beb89 commit 0775c74

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/elementext.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ impl ElementExt for Element {
3535
String: PartialEq<K>,
3636
{
3737
if let Some(child) = self.get_child(k) {
38-
Ok(Some(child.get_text().map(|s| s.to_owned())?))
38+
match child.get_text() {
39+
Err(e) => match e.downcast_ref() {
40+
// if tag is empty just ignore it
41+
Some(SVDError::EmptyTag(_, _)) => Ok(None),
42+
_ => return Err(e),
43+
},
44+
Ok(s) => Ok(Some(s.to_owned())),
45+
}
3946
} else {
4047
Ok(None)
4148
}

0 commit comments

Comments
 (0)