C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » XML »

Error while parsing


Posted Date: 05 Nov 2009      Posted By: Chandan      Member Level: Gold     Points: 1   Responses: 4




Hi When I add below tag in my xml file I am getting "An invalid character was found in text content." error.

<Program funcNbr="80000426" Desc="Meter Reading" FullName="TWACS – Meter Reading" Grouping="6" PrgmMnemonic="TWPB" PrgmGroup="PUB" PrgmName="TWACMDSK" UpdateFlg="Yes" ExclAccessFlag="No" OptAvailable="1" HelpIndex="1" System="CA" HelpFile="Help/Under_Development_2.htm" RptColumns="132">
</Program>

I need to add above mentioned element in
<Program Desc="TWACS">
</Program> This root tag.

Please tell me what is wrong asap...

Regards,
Chandan Gupta





Responses

Author: Lalji    05 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

You get this error if your XML contains non ASCII characters, and the file was saved as single-byte ANSI (or ASCII) with no encoding specified

more about this error
--------------
http://geekswithblogs.net/influent1/archive/2007/06/29/113594.aspx



Author: Anuraj    05 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Check this link

http://support.microsoft.com/kb/238833

Thanks
Anuraj
THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS.
BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT.
dotnetthoghts



Author: Dhanesh.K.R    05 Nov 2009Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

There may be some character entry mistakes

Try this link

http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entities_in_XML



Author: Zelalem    15 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

The XML works fine. I test it as is. Please see the code
First you need to add system.xml namespace

XmlDocument xdoc = new XmlDocument();
xdoc.Load(@"D:\WPF_Projects\ConsoleApplication2\XMLFile1.xml");
XmlNodeList list = xdoc.GetElementsByTagName("Program");
foreach (XmlNode node in list)
{

}

remember, my xml is just an xml file that contains your xml element without any modification.
<?xml version="1.0" encoding="utf-8" ?>
<Program funcNbr="80000426" Desc="Meter Reading" FullName="TWACS – Meter Reading" Grouping="6" PrgmMnemonic="TWPB" PrgmGroup="PUB" PrgmName="TWACMDSK" UpdateFlg="Yes" ExclAccessFlag="No" OptAvailable="1" HelpIndex="1" System="CA" HelpFile="Help/Under_Development_2.htm" RptColumns="132">
</Program>
So the problem might be somewhere else. I will be glad to see details of the error message you recieved. Please see the attached screenshot i took during debugging of the app that loads and parses the above xml file.



xmlForum.docx
Post Reply
You must Sign In to post a response.
Next : Please provide urgent fix on XML error while passing xml in Websevice.
Previous : How to read the xml data from the browser page and take it into xml file?
Return to Discussion Forum
Post New Message
Category: XML

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use