Error parsing XML in Firefox. No valid Character ""

Hello everyone, I have a problem parsing an XML file on Firefox. The XML i generated with a C# code which does not have any problem,  I use JavaScript for parsing other XML documents and there are no problems. But with my application (C#), sometimes an invalid character is set to an attribute of a node when the XML is generated.

Here is a description of my problem.

The information of this node is gotten from a record in a table of an MSI file.

dir: install
file: setup.msi
table: control
record:
    Dialog_                  Control                Type                     Attibutes              Text
    "ThisDialog"          "myControl"         "ScrollBarText"        "7"                 "The text 
 I want to parse it "



I dont have problems parsing 
 but with 

The complete Message I recieve on Firebug is
Error de lectura XML: referencia a un número de carácter no válido Ubicación:"path of XML File"

In english should be something like "XML reading Error: reference to a no valid character number located: "path of XML file""

I'll attach the Java Script code when i create the XMLDOM object.

I've benn thinking about replace that character for 
 or simply remove it from the "Text" Attribute but i dont have problems when i open it with IE.

So Im not sure if there is a way to parse that character. Any solution will be glad.
<dir name="install">
   <file name="setup.msi">
      <table name="Control">
         <record Dialog_="ThisDialog" Control= "myControl" Type="ScrollBarText" Attributes="7" Text="This is my text &#xA; and i want to parse it &#xF;" />
      </table>
   </file>
</dir>
 
 
JavaScript Code
 
 
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.async = false;
try {xmlDoc.load(xmlFile);}
catch (oError) {alert(oError.description + oError);return false; }
xmlObj=xmlDoc.documentElement; <-----Here is the error xmlObj gets a <parsererror> node, so, Im not able to process the data on the web page.

Open in new window

AlexIraMtyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michel PlungjanIT ExpertCommented:
what happens if you change it to
&#15;

instead?

It is not a visible char anyway
0
AlexIraMtyAuthor Commented:
I tried changing the char directly on the XML but soes not work. Actually that char does not supose that is set by user or by me, The C# application read a directory a automatically generates the XML tree with the attributes of each file or folder, so, the record inside the table inside msi comes with that char, its imposible change, only detect the node that contaisn in the attribute Text that char. I try to to this with the next Xpaht predicate.


string qDataNode = "//merge/data";
string query = "descendant::record[@Text[contains(.,'&#xF')]]";
XmlNode root = xmlDoc.DocumentElement;
XmlNode temp;
XmlNodeList node;
temp = root.SelectSingleNode(qDataNode);
node = temp.SelectNodes(query);
 
// if I try with the next code it returns a some nodes but im not
//able to find that node with le last predicate
 
string qDataNode = "//merge/data";
string query = "descendant::record[@Control[contains(.,'myControl')]]";
XmlNode root = xmlDoc.DocumentElement;
XmlNode temp;
XmlNodeList node;
temp = root.SelectSingleNode(qDataNode);
node = temp.SelectNodes(query);
 
 
//supose that XML has now the next structure
 
<merge>
   <data>
      <dir name="install">
         <file name="setup.msi">
            <table name="Control">
               <record Dialog_="ThisDialog" Control= "myControl" Type="ScrollBarText" Attributes="7" Text="This is my text &#xA; and i want to parse it &#xF;" />
               <record Dialog_="Newdialog" Control= "BannerLine" Type="Line" Attributes="1" Text="" />
            </table>
            <table name="Other_table">
               <record Dialog_="ReadyToInstall" Control="Branding2" Type="Text" X="3" Y="228"/>
               <record Dialog_="SetupError" Control="I" Type="PushButton" X="192" Y="80" Text = "This is other text with no invalid chars"/>
            </table>
         </file>
         <file name="setup.exe" size="6354" />
         <file name="newfile.dat" size ="1" />
      </dir>
      <dir name="otrodir">
         <dir name="DirInside_otrodir">
            <file name="last_file.ini">
         <dir/>
         <file name="update.exe" size="123">
      </dir>
   </data>
</merge>

Open in new window

0
Michel PlungjanIT ExpertCommented:
Sorry, I have no other ideas
0
AlexIraMtyAuthor Commented:
Well, I dont know if I have to set more points to my questions in order to get assistance from more people but I finally found a way to solve my own problem. I think I'll start to try to answer questions instead of ask them. Well Here is my solution...
//I decalrated next function
 
static XmlDocument delNoValidChars (XmlDocument xmlDoc)
{    
    StringWriter sw = new StringWriter();
    XmlTextWriter xw = new XmlTextWriter(sw);
    string temp, str;
    xmlDoc.WriteTo(xw);
    //str = xw.ToString();
    str = sw.ToString();
    temp = str;
    if (str.Contains("&#xF;"))
        str = sw.ToString().Replace("&#xF;", "");
    xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(str);
    return xmlDoc;
}
 
//I dont think I have to explain it to much, the code talks by it self
 
//There are 10 kinds of people, those who understand binary and those who do not.

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Michel PlungjanIT ExpertCommented:
Great.

I fixed your spelling in the joke for you ;)))
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.