Hi,
We need to Split the XML files based on the Element "CASE". While splitting it is converting Hexadecimal entities into UTF entities. We're new to this, you can understand our level of standard by analyzing the codings.
Please see the XML file and Csharp File for xml Conversion.
XML File
Code:
<ROOT>
<CASE>
<TB>U. S. DISTRICT COURT, EASTERN DISTRICT OF TEXAS</TB>
<LC>CAMPBELL V. WATTS</LC>, <DN>No. 70</DN>, <DD>Feb. 23, 1942</DD>
<SL>FAIR LABOR STANDARDS ACT</SL>
<DE>— Overtime standard — Burden of proof—Evidence</DE>
<PA>In action to recover unpaid overtime compensation under Act, employee has burden of showing with definiteness and certainty that he worked overtime.</PA>
</CASE>
<CASE>
<TB>2nd Chance</TB>
<LC>CAMPBELL V. WATTS</LC>, <DN>No. 70</DN>, <DD>Feb. 23, 1942</DD>
<SL>FAIR LABOR STANDARDS ACT</SL>
<DE>— Overtime standard — Burden of proof—Evidence</DE>
<PA>In action to recover unpaid overtime compensation under Act, employee has burden of showing with definiteness and certainty that he worked overtime.</PA>
</CASE>
</ROOT>
CSharp Coding
Code:
XmlDocument xmlReXML = new XmlDocument();
xmlReXML.Load(@"c:\Shorttag.xml");
XmlNodeList xnRep = xmlReXML.DocumentElement.GetElementsByTagName("CASE");
string strFileName = "CASE";
int intFileCount;
for(int i =0; i <xnRep.Count;i++)
{
//Stores the CASE Elements in the Variable
strDest = xnRep[i].InnerXml;
//Create the New File with the name "CASE_1.xml" and "CASE_3.xml"
XmlWriter xw = XmlWriter.Create(strFileName + "_" + intFileCount + ".xml");
//Write the XML
xw.WriteRaw(strDest.ToString());
xw.Close();
intFileCount++;
}
Current Output
Code:
<?xml version="1.0" encoding="utf-8"?><TB>U. S. DISTRICT COURT, EASTERN DISTRICT OF TEXAS</TB><LC>CAMPBELL V. WATTS</LC>, <DN>No. 70</DN>, <DD>Feb. 23, 1942</DD><SL>FAIR LABOR STANDARDS ACT</SL><DE>ââ¬â Overtime standard ââ¬â Burden of proofââ¬âEvidence</DE><PA>In action to recover unpaid overtime compensation under Act, employee has burden of showing with definiteness and certainty that he worked overtime.</PA><PA>Evidence held not to show with definiteness and certainty that employee worked an average of 16 hours a day as he claims, precluding him from recovering from employer overtime compensation under Act.</PA>
We need to split the xml file by retaining the entities and also its structure(entermarks) like the original.
Expecting your kind support to solve this..