Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / July 2008

Tip: Looking for answers? Try searching our database.

Invalid Name Character

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vinod - 11 Jul 2008 00:00 GMT
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>詳細仕様に</Name>

code:

strvalue = "詳細仕様に"

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
Martin Honnen - 11 Jul 2008 12:33 GMT
> Hi All,
>
[quoted text clipped - 44 lines]
> I am getting an error in base.WriteEntityRef as "Invalid name character in
> &#x8A73" and please let me know how to resolve it.

What is the value passed to WriteEntityRef?
What do you want to achieve?
If you want to write a character reference to a character then use
WriteCharEntity e.g.
  writer.WriteCharEntity('a')
if you want to write an entity reference then use WriteEntityRef and
pass in the name of the entity e.g.
  writer.WriteEntityRef("apos")

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.