c# - XML Parsing Error: not well-formed error -
i trying parse database feed data xml, on client side keep getting error:
xml parsing error: not well-formed location: http://localhost:12736/test.aspx line number 7, column 26: <publication date>29/04/2015 09:40:53</publication date> ------------------^
i have tried converting datetime parameter 'activatedate' string, still getting same error on 'publication date' node. have tried looking online solution still unable solve this.
here server code further reference:
response.clear(); response.contenttype = "text/xml"; using (xmltextwriter xml = new xmltextwriter(response.outputstream, encoding.utf8)) { xml.formatting = formatting.indented; xml.indentation = 4; xml.writestartdocument(); xml.writestartelement("items"); foreach (datarow ofeeditem in dt.rows) { // datetime dtt = datetime.parse(ofeeditem["activedate"].tostring()); string dat = convert.tostring(ofeeditem["activedate"].tostring()); // dat.tostring("dd mmmm yyyy"); xml.writestartelement("article"); xml.writeelementstring("title", ofeeditem["title"].tostring()); xml.writestartelement("description"); xml.writecdata(ofeeditem["body"].tostring()); xml.writeendelement(); xml.writeelementstring("categories", ofeeditem["categories"].tostring()); xml.writeelementstring("publication date", dat); xml.writeendelement(); } xml.writeendelement(); xml.writeenddocument(); xml.flush(); xml.close(); response.end(); }
thank suggestion , feedback.
xml element names can't contain spaces.
w3c specification declares xml tag as:
'<' name (s attribute)* s? '>'
where s
1 or more whitespace characters (#x20 | #x9 | #xd | #xa).
so specification seen space (#x20) considered delimiter between element name , attributes list - name can't contain spaces.
changing element publication date
name publication_date
make xml well-formed.
xml.writeelementstring("publication_date", dat);
Comments
Post a Comment