Please help in XMLReader of c#.NET
-
I'm using .net 1.1 Now I have tried with the code: System.Text.ASCIIEncoding encoder=new System.Text.ASCIIEncoding(); byte bytes=encoder.GetBytes(p_strXmlFrag); //Here its giving error MemoryStream ms=new MemoryStream(bytes); XmlWriter writer=XmlWriter.Create(ms); //Here it could not find create method ms.Position=0; XmlTextReader.xmlFile=new XmlTextReader(ms); ---- ---- ---- ---- ------------------------------------------------------------------------------------------------------------------------------------------------------------------ I'm also pasting the total method code to make it clear: public static bool Validate(string p_strMmlFrag, out string p_strErr) { p_strErr=string.Empty; //starting of if statement if m_xsc==null) { m_xsc=new XmlSchemaCollection(); try { string path=AppDomain.CurrentDomain.BaseDirectory+m_strSchema; if (!File.Exists(path)) { path=AppDomain.CurrentDoamin.BaseDirectory+"/bin"+m_strSchema; } XmlTextReader xmlFile=new XmlTextReader(path); m_ifSchema=XmlSchema.Read(xmlFile, new ValidationEventHandler (ValidationCallBack)); //Error rises in the above line as the destination file path (stored in path variable), I have just created (the file) and it's definitely empty. I tried the above mentioned solution but it's giving error!!!!!!!! m_xsc.Add(m_ifSchema); } // ending of if statement catch { ----- } ------- ------ ------- ------ private const string m_strSchema="StructureLinkage.xsd" private static XmlSchemaCollection=m_xsc; private static XmlSchema m_ifSchema; // For the first time only m_xsc in null and after that it does not need to enter into above block of code once m_xsc is instantiated. }
-
I'm using .net 1.1 Now I have tried with the code: System.Text.ASCIIEncoding encoder=new System.Text.ASCIIEncoding(); byte bytes=encoder.GetBytes(p_strXmlFrag); //Here its giving error MemoryStream ms=new MemoryStream(bytes); XmlWriter writer=XmlWriter.Create(ms); //Here it could not find create method ms.Position=0; XmlTextReader.xmlFile=new XmlTextReader(ms); ---- ---- ---- ---- ------------------------------------------------------------------------------------------------------------------------------------------------------------------ I'm also pasting the total method code to make it clear: public static bool Validate(string p_strMmlFrag, out string p_strErr) { p_strErr=string.Empty; //starting of if statement if m_xsc==null) { m_xsc=new XmlSchemaCollection(); try { string path=AppDomain.CurrentDomain.BaseDirectory+m_strSchema; if (!File.Exists(path)) { path=AppDomain.CurrentDoamin.BaseDirectory+"/bin"+m_strSchema; } XmlTextReader xmlFile=new XmlTextReader(path); m_ifSchema=XmlSchema.Read(xmlFile, new ValidationEventHandler (ValidationCallBack)); //Error rises in the above line as the destination file path (stored in path variable), I have just created (the file) and it's definitely empty. I tried the above mentioned solution but it's giving error!!!!!!!! m_xsc.Add(m_ifSchema); } // ending of if statement catch { ----- } ------- ------ ------- ------ private const string m_strSchema="StructureLinkage.xsd" private static XmlSchemaCollection=m_xsc; private static XmlSchema m_ifSchema; // For the first time only m_xsc in null and after that it does not need to enter into above block of code once m_xsc is instantiated. }
You already got an answer for this question in the C# forum (answer[^]). Instead of simply reposting the question in another forum, you should try to understand what you were told in the answer and work with that info.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook