Hello friends,
We have a big XML file (>27MB) to be parsed. We had deserialized the XML file into a XmlData object. The data from the XML is perfectly saved in this XmlData object in a proper structure of classes and objects.
Now, the goal here is to get the specific node data from the XmlData based on the Selected Node Path. I believe this can be done using Linq to XML query [Or] XPath.
But, I dont prefer Linq to XML because in this case i have to write specific query for specific node and i may have to hardcode the Specific Node names. This will be tough due to the complexity and imense XML data.
In case of XPath, i think we just need to provide the Selected node path and it will collect the corresponding data under it.
For eg. If i need to get the data under DOC-REVISIONS, then i will just send the Node path and retrieve all the data under it in Obj variable.
var Obj = Xpath (/node/path) [PS: plz ignore the syntax]
And this variable i want to use in my application.
Please can somebody guide me how i can achieve this.
Below mentioned is the code snippet and XML snippet, for your reference:
public void CreateDeserializedXmlObject(string strSrcFilename)
{
try
{
XmlSerializer deserializer = new XmlSerializer(typeof(ABC));
TextReader reader = new StreamReader(strSrcFilename);
object obj = deserializer.Deserialize(reader);
XmlData = (ABC)obj;
reader.Close();
}
catch (Exception ex)
{}
}
="1.0"="ISO-8859-1"="yes"
<ABC xmlns="http://www.ABC.net/schema/ABC/r1.0">
<CATEGORY>TestReport</CATEGORY>
<ADMIN-DATA>
<LANGUAGE>DE</LANGUAGE>
<USED-LANGUAGES>
<L-10 xml:space="preserve" L="EN">EN</L-10>
</USED-LANGUAGES>
<DOC-REVISIONS>
<DOC-REVISION>
<REVISION-LABEL>1.0.0.1</REVISION-LABEL>
<STATE>under_develpment</STATE>
<TEAM-MEMBER-REF DEST="TEAM-MEMBER">/EBCG/rm</TEAM-MEMBER-REF>
<DATE>2015-03-27</DATE>
</DOC-REVISION>
<DOC-REVISION>
<REVISION-LABEL>1.0.0.0</REVISION-LABEL>
<STATE>under_develpment</STATE>
<TEAM-MEMBER-REF DEST="TEAM-MEMBER">/XYZ/dro</TEAM-MEMBER-REF>
<DATE>2015-03-25</DATE>
</DOC-REVISION>
</DOC-REVISIONS>
</ADMIN-DATA>
Thanks.