I have big 7GB xml file ,and i am pasting small portion here
<?xml version="1.0" encoding="UTF-8"?>
<bulkFile xmlns:un="utranNrm.xsd"
xmlns:es="Attributes.15.25.xsd"
xmlns:xn="generic.xsd" xmlns:gn="geran.xsd" xmlns="configData.xsd">
<fileHeader fileFormatVersion="32.615 V4.5" Name="Wmart"/>
<configData dnPrefix="Undefined">
<xn:SubNetwork id="M_ROOT">
<xn:VsDataContainer id="1">
<xn:attributes>
<xn:vsDataType>vsDataAreas</xn:vsDataType>
<xn:vsDataFormatVersion>SpecificAttributes</xn:vsDataFormatVersion>
<es:vsDataAreas/>
</xn:attributes>
<xn:VsDataContainer id="424_2_2">
<xn:attributes>
<xn:vsDataType>vsDataPlmn</xn:vsDataType>
<xn:vsDataFormatVersion>SpecificAttributes</xn:vsDataFormatVersion>
<es:vsDataPlmn>
<es:userLabel></es:userLabel>
<es:mcc>424</es:mcc>
<es:mnc>2</es:mnc>
<es:mncLength>2</es:mncLength>
<es:aliasPlmnIdentities>
<es:mcc>424</es:mcc>
<es:mnc>2</es:mnc>
<es:mncLength>2</es:mncLength>
</es:aliasPlmnIdentities>
</es:vsDataPlmn>
</xn:attributes>
<xn:VsDataContainer id="10">
<xn:attributes>
<xn:vsDataType>vsDataLocationArea</xn:vsDataType>
<xn:vsDataFormatVersion>SpecificAttributes</xn:vsDataFormatVersion>
<es:vsDataLocationArea>
<es:userLabel></es:userLabel>
<es:lac>10</es:lac>
<es:t3212>10</es:t3212>
<es:att>1</es:att>
</es:vsDataLocationArea>
</xn:attributes>
</xn:VsDataContainer>
</xn:VsDataContainer>
</xn:VsDataContainer>
<xn:SubNetwork id="G-Mum">
<xn:attributes>
<xn:userDefinedNetworkType>SiteSolutions</xn:userDefinedNetworkType>
<xn:userLabel>G-Mum</xn:userLabel>
</xn:attributes>
<xn:MeContext id="32509_I_East">
<xn:VsDataContainer id="23502_I_AAN_UAEU_Crescent_East">
<xn:attributes>
<xn:vsDataType>vsDataMeContext</xn:vsDataType>
<xn:vsDataFormatVersion>EricssonSpecificAttributes.15.25</xn:vsDataFormatVersion>
<es:vsDataMeContext>
<es:userLabel>23502_I_AAN_UAEU_Crescent_East</es:userLabel>
<es:ipAddress>10.235.20.10</es:ipAddress>
<es:neMIMversion>vF.1.108</es:neMIMversion>
<es:lostSynchronisation>SYNCHRONISED</es:lostSynchronisation>
<es:bcrLastChange>1474785017888</es:bcrLastChange>
<es:bctLastChange>1470699087457</es:bctLastChange>
<es:multiStandardRbs6k>false</es:multiStandardRbs6k>
<es:mixedModeRadio>false</es:mixedModeRadio>
<es:mirrorMIBversion>F.1.100.S.1.6</es:mirrorMIBversion>
<es:stnNodes></es:stnNodes>
</es:vsDataMeContext>
</xn:attributes>
</xn:VsDataContainer>
<xn:ManagedElement id="1">
<xn:attributes>
</xn:attributes>
<xn:VsDataContainer id="1">
<xn:attributes>
<xn:vsDataType>vsDataManagedElement</xn:vsDataType>
<xn:vsDataFormatVersion>Attributes.15.25.xsd</xn:vsDataFormatVersion>
<es:vsDataManagedElement>
<es:siteRef>SubNetwork=M_ROOT,Site=32509_I_East</es:siteRef>
<es:productType>Node</es:productType>
<es:productName>RBS6601L</es:productName>
<es:productNumber></es:productNumber>
<es:productRevision></es:productRevision>
<es:prodDesignation>0</es:prodDesignation>
</es:vsDataManagedElement>
</xn:attributes>
</xn:VsDataContainer>
.
.
<xn:VsDataContainer id="1">
<xn:attributes>
<xn:vsDataType>vsDataENodeBFunction</xn:vsDataType>
<xn:vsDataFormatVersion>Attributes.15.25.xsd</xn:vsDataFormatVersion>
<es:vsDataENodeBFunction>
<es:userLabel></es:userLabel>
<es:dscpLabel>24</es:dscpLabel>
<es:dnsLookupOnTai>1</es:dnsLookupOnTai>
<es:eNBId>32509</es:eNBId>
</es:vsDataENodeBFunction>
</xn:attributes>
<xn:VsDataContainer id="BC_3250_32509_L1_B">
<xn:attributes>
<xn:vsDataType>vsDataEUtranCellFDD</xn:vsDataType>
<es:earfcndl>1651</es:earfcndl>
<es:earfcnul>19651</es:earfcnul>
</xn:attributes>
</xn:VsDataContainer>
..
<xn:VsDataContainer id="BD_4250_32509_L1_B">
<xn:attributes>
<xn:vsDataType>vsDataEUtranCellFDD</xn:vsDataType>
<es:earfcndl>1651</es:earfcndl>
<es:earfcnul>19651</es:earfcnul>
</xn:attributes>
</xn:VsDataContainer>
<xn:VsDataContainer id="CC_3250_32509_L1_C">
<xn:attributes>
<xn:vsDataType>testranCellFDD</xn:vsDataType>
<es:earfcndl>165</es:earfcndl>
<es:earfcnul>19651</es:earfcnul>
</xn:attributes>
</xn:VsDataContainer>
</xn:VsDataContainer>
..
</xn:ManagedElement>
</xn:MeContext>
<xn:MeContext id="32509_I_west">
<xn:VsDataContainer id="32509_I_AAN_UAEU_Crescent_East">
<xn:attributes>
<xn:vsDataType>vsDataMeContext</xn:vsDataType>
<xn:vsDataFormatVersion>Attributes.15.25</xn:vsDataFormatVersion>
<es:vsDataMeContext>
<es:userLabel>32509_I_AAN_UAEU_Crescent_East</es:userLabel>
<es:ipAddress>10.235.20.10</es:ipAddress>
<es:neMIMversion>vF.1.108</es:neMIMversion>
<es:lostSynchronisation>SYNCHRONISED</es:lostSynchronisation>
<es:bcrLastChange>1474785017888</es:bcrLastChange>
<es:bctLastChange>1470699087457</es:bctLastChange>
<es:multiStandardRbs6k>false</es:multiStandardRbs6k>
<es:mixedModeRadio>false</es:mixedModeRadio>
<es:mirrorMIBversion>F.1.100.S.1.6</es:mirrorMIBversion>
<es:stnNodes></es:stnNodes>
</es:vsDataMeContext>
</xn:attributes>
</xn:VsDataContainer>
<xn:ManagedElement id="1">
<xn:attributes>
</xn:attributes>
<xn:VsDataContainer id="1">
<xn:attributes>
<xn:vsDataType>vsDataManagedElement</xn:vsDataType>
<xn:vsDataFormatVersion>Attributes.15.25.xsd</xn:vsDataFormatVersion>
<es:vsDataManagedElement>
<es:siteRef>SubNetwork=M_ROOT,Site=32509_I_East</es:siteRef>
<es:productType>Node</es:productType>
<es:productName>RBS6601L</es:productName>
<es:productNumber></es:productNumber>
<es:productRevision></es:productRevision>
<es:prodDesignation>0</es:prodDesignation>
</es:vsDataManagedElement>
</xn:attributes>
</xn:VsDataContainer>
.
.
<xn:VsDataContainer id="1">
<xn:attributes>
<xn:vsDataType>vsDataENodeBFunction</xn:vsDataType>
<xn:vsDataFormatVersion>Attributes.15.25.xsd</xn:vsDataFormatVersion>
<es:vsDataENodeBFunction>
<es:userLabel></es:userLabel>
<es:dscpLabel>24</es:dscpLabel>
<es:dnsLookupOnTai>1</es:dnsLookupOnTai>
<es:eNBId>32509</es:eNBId>
</es:vsDataENodeBFunction>
</xn:attributes>
<xn:VsDataContainer id="CC_3250_32509_L1_B">
<xn:attributes>
<xn:vsDataType>vsDataEUtranCellFDD</xn:vsDataType>
<es:earfcndl>1651</es:earfcndl>
<es:earfcnul>19651</es:earfcnul>
</xn:attributes>
</xn:VsDataContainer>
..
<xn:VsDataContainer id="CD_4250_32509_L1_B">
<xn:attributes>
<xn:vsDataType>vsDataEUtranCellFDD</xn:vsDataType>
<es:earfcndl>1651</es:earfcndl>
<es:earfcnul>19651</es:earfcnul>
</xn:attributes>
</xn:VsDataContainer>
<xn:VsDataContainer id="DC_3250_32509_L1_C">
<xn:attributes>
<xn:vsDataType>testranCellFDD</xn:vsDataType>
<es:earfcndl>165</es:earfcndl>
<es:earfcnul>19651</es:earfcnul>
</xn:attributes>
</xn:VsDataContainer>
</xn:VsDataContainer>
..
</xn:ManagedElement>
</xn:MeContext>
</xn:SubNetwork>
</xn:SubNetwork>
</configData>
</bulkFile>
Here i want to get values for c# variables i declared which are like subnetwork
,sitename
,eNBId
,cellname
,earfcndl
and earfcnul
all the information's resides under root tag <xn:SubNetwork id="M_ROOT">
tag,rest all for all sites coming under the root and here i am pasting only one site details.The logic is
subnetwork = <xn:SubNetwork id > attribute value
sitename = <xn:MeContext id> attribute value
eNBId = <es:eNBId> value, here the important thing is, there will be huge number of `<xn:VsDataContainer id="1">` parent tag,but the filtration is based on `<xn:vsDataType>` inner tag which is of `vsDataENodeBFunction`.
cellname = `<xn:VsDataContainer id>` attribute value and
`earfcndl` and `earfcnul` is values for `<es:earfcndl> and <es:earfcnul>` tag .Here also filtration is based on <xn:vsDataType>vsDataEUtranCellFDD</xn:vsDataType>
so i want to get subnetwork = G-Mum,,sitename = 32509_I_East,,eNBId=32509,,cellname=BC_3250_32509_L1_B,,earfcndl=1651,,earfcnul=19651
.
Here i did following code, but got stuck and don't know what to do.But i can guarantee that this is the only way(xmlreader
and (XElement)XNode.ReadFrom
method) we can read 7Gb Xml file,rest all will throw "Out of memory exceptions"
using (XmlReader xr = XmlReader.Create(path))
{
xr.MoveToContent();
XNamespace un = xr.LookupNamespace("un");
while (xr.Read())
{
while (xr.NodeType == XmlNodeType.Element && xr.NamespaceURI == un && xr.LocalName == "M_ROOT")
{
XElement pin = (XElement)XNode.ReadFrom(xr);
var data = from atts in pin.Elements(un + "attributes")
select new
{
eNBId= (string)atts.Element(es + "eNBId"),
}
}
}
EDIT Hierarchy is only one xn:SubNetwork id="M_ROOT" tag which contain all the regions like which again contains all the site information's under tag which again contains all the cell information's under of type vsDataEUtranCellFDD
EDIT @jdweng thanks for your help,now they have increased xml again,and now the snippet xml which we took by using the(XElement)XElement.ReadFrom(reader); itself throwing the Out of memory exception.How can i remove the unnecessary xml part.My hierarchy is
<xn:SubNetwork id="M_ROOT">--------------Root
<xn:SubNetwork id="G-Mum">---------Region
<xn:MeContext id="32509_I_East">-----sites
<xn:VsDataContainer id="BC_3250_32509_L1_B"> ---Cells
<xn:attributes>
<xn:vsDataType>vsDataEUtranCellFDD</xn:vsDataType>
</xn:MeContext>
</xn:SubNetwork>
</xn:SubNetwork>
SO what ever i posted on the very begging of my question is necessary data,rest all unnecessary
EDIT @jdweng ,yes what ever i posted is the required on,I am editing my question again. Heirarchy is
`<xn:SubNetwork>` --------Root and only one
Then after several line
<xn:SubNetwork>
contain Regions will come as groups,But here only id begins with G-
is valid so here G-Mum
Then <xn:MeContext>
contains sites will come as groups which again contains lot of <xn:VsDataContainer>
,but here one contains child node <xn:vsDataType>vsDataManagedElement</xn:vsDataType>
is valid one in order to get <es:eNBId>
.
Then again after several lines <xn:VsDataContainer>
of child nodes <xn:vsDataType>vsDataEUtranCellFDD</xn:vsDataType>
contains cells will come.This(cells) is the inner most one.
SO there will be huge number of <xn:VsDataContainer>
will come,out of it only of child nodes <xn:vsDataType>vsDataENodeBFunction</xn:vsDataType>
for getting Enbid
and <xn:vsDataType>vsDataEUtranCellFDD</xn:vsDataType>
for cells are import
EDIT After analyzing big file i came to know that cells are coming under sites ,but i posted it in out side,Ie vsDataEUtranCellFDD is coming under the tag vsDataENodeBFunction.I have edited my xml which i posted
EDIT 10/10/16
There is little change in xml ,one more VsDataContainer
was there before VsDataContainer
of <xn:vsDataType>vsDataENodeBFunction</xn:vsDataType>
,Due to that vsDataENodeBFunction
is not caught.I used Skip(1)
but didn't work
vsDataManagedElement
Below should fix the issue with earfcndl and earfcnul
You have a very large file so it is best to use XmlReader. Try this code
Use following code to get a small portion of xml