question

AshishKaundal-6518 avatar image
0 Votes"
AshishKaundal-6518 asked AshishKaundal-6518 commented

Split XML file on basis Days, Weeks and Hours.

<tv xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">;
<channel id="29">
<icon src="https://29_discovery.jpg"/>
</channel>
<programme start="20210702113620" stop="20210702003620" channel="29">
<desc lang="">ABC</desc>
<title lang="">XYZ</title>
</programme>
<programme start="20210702003620" stop="20210702013620" channel="29">
<desc lang="">DEF</desc>
<title lang="">hjk</title>
</programme>
<programme start="20210702013620" stop="20210702023620" channel="29">
<desc lang="">GHI</desc>
<title lang="">vbn</title>
</programme>
<programme start="20210702184120" stop="20210702194120" channel="29">
<desc lang="">ABC</desc>
<title lang="">XYZ</title>
</programme>
<programme start="20210702194120" stop="20210702204120" channel="29">
<desc lang="">DEF</desc>
<title lang="">hjk</title>
</programme>
<programme start="20210702204120" stop="20210702214120" channel="29">
<desc lang="">GHI</desc>
<title lang="">vbn</title>
</programme>
<programme start="20210702131120" stop="20210702141120" channel="29">
<desc lang="">ABC</desc>
<title lang="">XYZ</title>
</programme>
<programme start="20210702141120" stop="20210702151120" channel="29">
<desc lang="">DEF</desc>
<title lang="">hjk</title>
</programme>
<programme start="20210702151120" stop="20210702161120" channel="29">
<desc lang="">GHI</desc>
<title lang="">vbn</title>
</programme>
</tv>

dotnet-csharp
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi AshishKaundal-6518,
>>Split XML file on basis Days, Weeks and Hours.
In order to understand your needs more accurately, please explain in detail.
Best Regards,
Daniel Zhang

1 Vote 1 ·

I want to split xml by days, weeks and hours by start and stop in xml file. This start and stop are formatted datetime yyyy/MM/dd hh/mm/ss but I save this date without any space in xml.

In this case if user click on weeks, then the xml file split by weeks from start and stop datetime.
If user click on Hours, The xml file split by hours from start and stop date time.
If user click on days, The xml file split by days from start and stop date time.

Thanks & Regards
Ashish

0 Votes 0 ·

Hi @AshishKaundal-6518,
I have a suggestion you can refer to.
First, you can use LinqToXml to write each element into different file.
Examples are provided in the following two links you can refer to.
Split into xml files retaining few tags from base xml file using linq
How to Split an XML file into multiple XML Files based on nodes
And then you can use XPath in XmlDocument.SelectNodes to filter out the corresponding single xml file according to the start and stop time.

 XmlNodeList nodes = xDoc.SelectNodes("//programme [@start='value1']");
 XmlNodeList nodes = xDoc.SelectNodes("//programme [@stop='value2']");

Here is a related thread.
The value1 is set as a variable, value2 can be increased by hour, day, and week.
Best Regards,
Daniel Zhang


1 Vote 1 ·
Show more comments

0 Answers