C
C#3y ago
Djinn

XML Deserialize error

Error
System.InvalidOperationException: There is an error in XML document (4, 2).
---> System.InvalidOperationException: <database xmlns='http://www.iw.com/sns/platform/'> was not expected.
System.InvalidOperationException: There is an error in XML document (4, 2).
---> System.InvalidOperationException: <database xmlns='http://www.iw.com/sns/platform/'> was not expected.
Code
var serializer = new XmlSerializer(typeof(XmlUtils));
var reader = XmlReader.Create("test.xml", new XmlReaderSettings
{
IgnoreComments = true,
IgnoreWhitespace = true,
LineNumberOffset = 2,
IgnoreProcessingInstructions = true,
});
serializer.Deserialize(reader);
var serializer = new XmlSerializer(typeof(XmlUtils));
var reader = XmlReader.Create("test.xml", new XmlReaderSettings
{
IgnoreComments = true,
IgnoreWhitespace = true,
LineNumberOffset = 2,
IgnoreProcessingInstructions = true,
});
serializer.Deserialize(reader);
xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<tns:database xmlns:tns="http://www.iw.com/sns/platform/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Group id="function_on">
<ItemSpec id="test" open="true">
</Group>
</tns:database>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<tns:database xmlns:tns="http://www.iw.com/sns/platform/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Group id="function_on">
<ItemSpec id="test" open="true">
</Group>
</tns:database>
4 Replies
Djinn
DjinnOP3y ago
How do i just simple parse groups and items inside this xml? looks like throws because its not like some schema
Anton
Anton3y ago
you didn't close ItemSpec
Djinn
DjinnOP3y ago
Djinn
DjinnOP3y ago
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<tns:database xmlns:tns="http://www.iw.com/sns/platform/">
<Group id="function_on">
<ItemSpec id="lua_fun_res_dy_btn" online="all" test="all" version="6.26.0" pf="all"/>


....


</Group>
</tns:database>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<tns:database xmlns:tns="http://www.iw.com/sns/platform/">
<Group id="function_on">
<ItemSpec id="lua_fun_res_dy_btn" online="all" test="all" version="6.26.0" pf="all"/>


....


</Group>
</tns:database>
Using valid xml (... For for a lot lines)
Want results from more Discord servers?
Add your server