Invalid Name Character

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Vmlub2Q=?=

    Invalid Name Character

    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(str ing strValue)
    {
    int intPstn;

    if(strValue.Ind exOf("&") != -1)
    {
    intPstn = 0;

    foreach(Match entMatch in rxEnt.Matches(s trValue))
    {
    base.WriteStrin g(strValue.Subs tring(intPstn, entMatch.Index - intPstn));

    try
    {
    base.WriteEntit yRef(entMatch.V alue);
    }
    catch
    {
    base.WriteStrin g(entMatch.Valu e);
    }

    intPstn = entMatch.Index + entMatch.Length ;
    }

    base.WriteStrin g(strValue.Subs tring(intPstn)) ;
    }
    else
    base.WriteStrin g(strValue);
    }


    Here the base class is XmlTextWriter.

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

    Regards,
    Vinod

  • Martin Honnen

    #2
    Re: Invalid Name Character

    Vinod wrote:
    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(str ing strValue)
    {
    int intPstn;
    >
    if(strValue.Ind exOf("&") != -1)
    {
    intPstn = 0;
    >
    foreach(Match entMatch in rxEnt.Matches(s trValue))
    {
    base.WriteStrin g(strValue.Subs tring(intPstn, entMatch.Index - intPstn));
    >
    try
    {
    base.WriteEntit yRef(entMatch.V alue);
    }
    catch
    {
    base.WriteStrin g(entMatch.Valu e);
    }
    >
    intPstn = entMatch.Index + entMatch.Length ;
    }
    >
    base.WriteStrin g(strValue.Subs tring(intPstn)) ;
    }
    else
    base.WriteStrin g(strValue);
    }
    >
    >
    Here the base class is XmlTextWriter.
    >
    I am getting an error in base.WriteEntit yRef 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.WriteCha rEntity('a')
    if you want to write an entity reference then use WriteEntityRef and
    pass in the name of the entity e.g.
    writer.WriteEnt ityRef("apos")

    --

    Martin Honnen --- MVP XML

    Comment

    Working...