Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Invalid Name character

Question posted by: banagani (Newbie) on July 10th, 2008 09:19 PM
Hi All,

I am facing an issue in the XmlTextWriter class in the dotnet 2.0.

This is the sample code

Actual XML is like this

<Name>&#x8A73;&#x7D30;&#x4ED5;&#x69D8;&#x306B;</Name>

code:

strvalue = "&#x8A73;&#x7D30;&#x4ED5;&#x69D8;&#x306B;"

public override void WriteString(string strValue)
{
int intPstn;

if(strValue.IndexOf("&#") != -1)
{
intPstn = 0;

foreach(Match entMatch in rxEnt.Matches(strValue))
{
base.WriteString(strValue.Substring(intPstn, entMatch.Index - intPstn));

try
{
base.WriteEntityRef(entMatch.Value);
}
catch
{
base.WriteString(entMatch.Value);
}

intPstn = entMatch.Index + entMatch.Length;
}

base.WriteString(strValue.Substring(intPstn));
}
else
base.WriteString(strValue);
}


Here the base class is XmlTextWriter.

I am getting an error in base.WriteEntityRef as "Invalid name character in &#x8A73" and please let me know how to resolve it.

Regards,
Vinod
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
jkmyoung's Avatar
jkmyoung
Moderator
765 Posts
July 14th, 2008
09:55 PM
#2

Re: Invalid Name character
See http://www.w3.org/TR/REC-xml/ particularly the section with NCName and NameChar

NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender

The particular character you're using is not valid for an element name.

Reply
Reply
Not the answer you were looking for? Post your question . . .
183,630 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top XML Forum Contributors