mirror of
https://github.com/vlang/v.git
synced 2025-09-16 19:06:24 -04:00
46 lines
864 B
V
46 lines
864 B
V
module main
|
|
|
|
import os
|
|
import encoding.xml
|
|
|
|
fn test_valid_parsing() {
|
|
path := os.join_path(os.dir(@FILE), 'attributes.xml')
|
|
|
|
expected := xml.XMLDocument{
|
|
root: xml.XMLNode{
|
|
name: 'book'
|
|
attributes: {
|
|
'category': 'web'
|
|
}
|
|
children: [
|
|
xml.XMLNode{
|
|
name: 'title'
|
|
attributes: {
|
|
'lang': 'en'
|
|
'code:type': 'const char*'
|
|
}
|
|
children: ['Learning XML']
|
|
},
|
|
xml.XMLNode{
|
|
name: 'author'
|
|
attributes: {
|
|
'attr': ' surrounding spaces '
|
|
}
|
|
children: ['Erik T. Ray']
|
|
},
|
|
xml.XMLNode{
|
|
name: 'year'
|
|
children: ['2003']
|
|
},
|
|
xml.XMLNode{
|
|
name: 'price'
|
|
children: ['39.95']
|
|
},
|
|
]
|
|
}
|
|
}
|
|
actual := xml.XMLDocument.from_file(path)!
|
|
|
|
assert expected == actual, 'Parsed XML document should be equal to expected XML document'
|
|
}
|