Connecting Tech Pros Worldwide Help | Site Map

Invalid Name Character

  #1  
Old July 11th, 2008, 12:05 AM
=?Utf-8?B?Vmlub2Q=?=
Guest
 
Posts: n/a
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

  #2  
Old July 11th, 2008, 12:45 PM
Martin Honnen
Guest
 
Posts: n/a

re: Invalid Name Character


Vinod wrote:
Quote:
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.
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")

--

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid Name character banagani answers 1 July 14th, 2008 10:55 PM
Invalid Name Character =?Utf-8?B?Vmlub2Q=?= answers 3 July 12th, 2008 08:15 AM
Unable to convert input xml file content to a DataSet/Invalid 'name' attribute value mahet answers 1 April 6th, 2007 02:03 PM
Invalid 'name' attribute name Anders Jansson answers 3 February 14th, 2006 06:15 PM