XML Deserialize error
Error
Code
xml
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.
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 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
How do i just simple parse groups and items inside this xml? looks like throws because its not like some schema
you didn't close ItemSpec
<?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>