AlexIraMty
asked on
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.
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 
 and i want to parse it " />
</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.
ASKER
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(.,'')]]";
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 
 and i want to parse it " />
<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>
Sorry, I have no other ideas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Great.
I fixed your spelling in the joke for you ;)))
I fixed your spelling in the joke for you ;)))

instead?
It is not a visible char anyway