How To Parse Nested Xml In Spark

Parsing a Basic XML using Hadoop and Spark Core APIs In the code snippet below we can see how the stream reader is configured. In order to read XML data it has to be a StreamXmlRecordReader. XML data alone can be extracted using: val top5duration = data. gq: SEO audit and website analysis in traffic, social media, performance, back links, visitors and more. The tree knows about all of the data in the input. All modern browsers have a built-in XML parser that can convert text into an XML DOM object. When you have to save hierarchical data inside a database you can traverse the tree with recursion and for each note call the database to save it. Since the whole XML document is not loaded into memory, such an application can be less memory-intensive in contast to using a DOM-based approach. Based in Chicago, IL, we are a well established company specializing in Big Data Governance! We work primarily in the Healthcare and Financial verticals- in North America and Europe. Working on Parquet files in Spark. SSIS XML Parser Transform. Thankfully this is very easy to do in Spark using Spark SQL DataFrames. Primarily used for transformation or extraction, it features filters, visitors, custom tags and easy to use JavaBeans. Parsing nested Json in a spark dataframe? (self. XML Data Binding makes it significantly easier to deal with XML documents from within your C# code, resulting in less code, which is simpler to read and maintain. If your XML file has lots of nested tags, you may want to use an XML viewer instead. NET - Dataset XML is a platform independent language, so the information formatted in XML can be use in any other platforms (Operating Systems). The ReadPropertiesXmlFile class is just like our ReadPropertiesFile class that we described in another tutorial, except that it reads 'test. There is a Spark XML library. val df = sqlContext. With Apache Spark you can easily read semi-structured files like JSON, CSV using standard library and XML files with spark-xml package. Your help would be appreciated. Docs - How to: parse and convert CSV files to XML. This topic compares a single-level FOR XML query to a nested FOR XML query. Parsing XML Documents. Provide a name to the metadata and click next. In most cases, you don’t have to go multiple levels deep, but it can entirely depend on the data set being represented by the XML. Apache Hadoop. The stream reader has to also know between which XML tags it can read in parallel chunks of data. The list will be evaluated first. In pseudo-code it can be implemented as:. Jan 16, 2018 · 3 min read. In order to generate a heirarchical/nested XML from a dataset, you need to define relations between your tables. Easily create stunning social graphics, short videos, and web pages that make you stand out on social and beyond. Hope this helps. Also updating the listview with parsed xml data. In a nutshell, XML stores information in a tree-based text format that allows both you and I as well as computers to easily read the data. So it's not right clear. From the data from DB i could generate the Clipboard structure, but i am not sure of generating the XML out of it. NET JavaScriptSerializer class. Nested XML The whole secret to parsing nested XML is to create parse handlers for each tag and switch them into place when that tag begins and restore the previous parse handler when that tag ends. Parsing Nested XML file – Learn more on the SQLServerCentral forums. Read your XML file. HibernateException: Could not parse configuration: hibernate. October 15, 2015 How To Parse and Convert JSON to CSV using Python May 20, 2016 How To Parse and Convert XML to CSV using Python November 3, 2015 Use JSPDF for Exporting Data HTML as PDF in 5 Easy Steps July 29, 2015 How To Manage SSH Keys Using Ansible August 26, 2015 How To Write Spark Applications in Python. Website Review of udaqagumyfih. 4) Also using 'dbms_xslprocessor' utility to handling the xml nodes. baahu June 24, 2017 No Comments on Spark: Read Xml files using XmlInputFormat Tweet There would be instances where in we are given a huge xml which contains smaller xmls and we need to extract the same for further processing. How to parse Nested XML using the SAX parser. The xml itself has a structure. In a previous article, we looked into parsing an XML file and converting it to DOM (Document Object Model). With nested paging, the hardware provides another level of indirection when translating linear to physical addresses. val xmlmodified = data. It can be very easy to use Spark to convert XML to Parquet and then query and analyse the output data. Complex XML dialplans are sometimes difficult to read and understand, which is why other dialplan processors are available. Any how I wrote a few articles about this topic a few weeks ago and also published source code for doing the conversion. We can parse normal xml file easily using scala XML support or even using databricks xml format, but how do I parse the xml embedded inside text. The XML DOM object itself is not very useful in an application unless it can be used to extract required data. xml' rather than 'test. Right click and create new XML file. Go to File -> New website. We are looking for an experienced Hadoop/ Spark (Scala) Data Engineer for our Chicago location This is a direct, full time role. One of the benefits of using nested FOR XML queries is that you can specify a combination of attribute-centric and element-centric XML for query results. Is there any news on this, I have not been able to use DS electrical since I re-installed it. 0 with a version 1. 1 employs Spark SQL's built-in functions to allow you to consume data from many sources and formats (JSON, Parquet, NoSQL), and easily perform transformations and interchange between these data formats (structured, semi-structured, and unstructured data). Below is the XML that is used in this application. How to read and write JSON files with Spark I wanted to build a Spark program that would read text file where every line in the file was a Complex JSON object like this. XML parsing requires a bit of evaluating the dataset and identifying where your data is located. To obtain values from nested XML tags, use tag names separated by a slash. Nested loop join is often defined as the most basic joining algorithm in SQL. The inbuilt Splunk python might not have XML-JSON conversion modules and we might need to import/install those specific modules to do this in the script. Home » Java » Parsing Highly Nested XML without DOM in Java. C# allows to use one loop inside another loop. And XML is 100% more human readable than binary and much easier than JSON if you're writing it by hand. XML : Bloodroot Sanguinaria canadensis 4 Mostly Shady $2. Author: Ankur Have worked primarily in the domain of Calling, CRM and direct advertisers services. It will also create appropriate IDs so nodes can be linked. Provide application name and set master to local with two threads. The inbuilt Splunk python might not have XML-JSON conversion modules and we might need to import/install those specific modules to do this in the script. XML processing on Spark. com alvin alexander. Your help would be appreciated. Either you convert it to a dataframe and then apply select or do a map operation over the RDD. (the java object is of many nested / referenced classes), and I. Parsing Nested XML in R In another blog post, I explore the database on grants awarded by the National Science Foundation since Between Jan. If you have have worked with XML and a repeater control, you know what I am talking about. This is somewhat related, but the Google Maps API does Geolocation with an XML parse to PHP in one of their early tutorials in exactly the way you are trying to access the XML. Problem: How to define Spark DataFrame using the nested array column (Array of Array)? Solution: Using StructType we can define an Array of Array (Nested Array) ArrayType(ArrayType(StringType)) DataFrame column using Scala example. Let's pretend that we're analyzing the file with the content listed below:. Build an interface which picks the csv file from System A and transform into target hierarchical structure using the importing java archive in the previous step and post the Output (File, IDoc, etc) into target system B. Nested XML The whole secret to parsing nested XML is to create parse handlers for each tag and switch them into place when that tag begins and restore the previous parse handler when that tag ends. Nested paths are evaluated in the order they appear in the task. tag]) is type ([]): # append to. When I put together the “Generics based Framework for. JAXB: Example of Nested List of XML Element June 3, 2017 java , jee java , javaee , jaxb , xml Ranjeet Jha This example demonstrate nested object meaning that , one container class which hold reference of another class. Key XML and Excel scenarios. Nested loop join is often defined as the most basic joining algorithm in SQL. This site uses cookies for analytics, personalized content and ads. How to use HBase-Spark Module. SELECT or Query nodes in hierarchial or nested XML. In order to read XML data it has to be a StreamXmlRecordReader. A property called Current which returns the "current" item in the enumerated list of values. Tag: hadoop,hive,apache-spark,parquet. I want to parse a nested xml file, this file will contain form inputs, because I want to create dynamic forms. Need help to parse the Nested JSON in spark Dataframe. Parquet stores nested data structures in a flat columnar format. The animal_interpretation column has a StructType type — this DataFrame has a nested schema. json Does not really work for me. Spark Packages, from Xml to Json. You can also opt to store the XML file in a directory in your file system but for simplicity's sake, we'll just include it in our project. There is a Spark XML library. xml file in our project. Inside node we have nested nodes for and our task is to read all the items with nested loops in their separate flow. You can optionaly specify a custom configurator. When I put together the “Generics based Framework for. And read the elements name. With capabilities like in-memory data storage and near real-time processing, the performance can be several times faster than other big data technologies. In order to read XML data it has to be a StreamXmlRecordReader. It takes the pain out of processing XML files on Spark. As I have outlined in a previous post, XML processing can be painful especially when you need to convert large volumes of complex XML files. Here is the requirement for our XML file. Thanks, Anthony - that code is helpful. I see data in attributes only, data in element nodes only, data at the top level, data several layers down, and all possible combinations of those things. Following section shows few examples to illustrate the concept. See the Spark dataframeReader "load" method. For example, we might want to parse a complex, densely nested object graph into a more straightforward model for use in another domain. XML Schema 1. I am trying to parse this xml in python and creating an. The structure and test tools are mostly copied from CSV Data Source for Spark. In this case, Excel doesn't infer a schema, and you can't use an XML Map. I've shown this with an example with 2 approaches/methods and it's up to you what to chose based upon their performance. JSON is a very common way to store data. HTML Parser HTML Parser is a Java library used to parse HTML in either a linear or nested fashion. Will sponsor Visa transfers!. My boss wants me to parse a set of query plans stored in a table and to determine how many nested loop operators with unordered prefetching are present in each plan. An article which shows how to enumerate over XML data in a foreach loop as if the data were in a collection. Recently, we have been interested on transforming of XML dataset to something easier to be queried. Learn how to work with Apache Spark DataFrames using Python in Databricks. Is there any way to map attribute with NAME and PVAL as value to Columns in dataframe?. Posted on July 11, 2017 by jinglucxo on spark read sequence file. With SHORTREF you declare text tokens to be replaced into other text (typically start- and end-element tags). The last blog post that I did focused on creating an XML document using LINQ to XML. they don't automate much. Note: There is a new version for this artifact. XMLID (text, parser=None) ¶ Parses an XML section from a string constant, and also returns a dictionary which maps from element id:s to elements. I was looking for a way to easily convert the yaml content into xml. The problem being is sending input as XML or HTML. In order to read XML data it has to be a StreamXmlRecordReader. Select the XML file under File Settings. "&" character is making your sender xml file invalid. Note that handling attributes can be disabled with the option excludeAttribute. Study Record Tabs. There are numerous ways to parse XML in Java but they are all based on one of the two technologies: DOM; SAX; I'm not going to explain what these two API's do exactly, there are plenty of articles on the subject, but in a nutshell, DOM gives you a tree view of your XML document, which you can then navigate by moving from one node to the other, while SAX is event. As noted previously, Version 6 JavaScript browsers seem to be coming together over the W3C DOM. One solution out of these uses SerDe properties in ROW FORMAT by adding a hivexmlserde jar file. How to extract values from a nested JSON field in SQL. JSON (JavaScript Object Notation) is a lightweight data-interchange format. xml' rather than 'test. read nested xml into a dataset Aug 1 2006 4:14 PM I have an xml file with nested nodes - i want to populate a dataset with those rows from the. So let's assume the query is nested like. If you're interested in SAX or STAX parser, please refer to these tutorials: SAX parser, STAX parser. You can also set a scroll position to display the contents at a current location within that range. Before you post your answer, please take a moment to go through our tips on great answers. When there are two records in xml file then seg:. Nested XML The whole secret to parsing nested XML is to create parse handlers for each tag and switch them into place when that tag begins and restore the previous parse handler when that tag ends. XML parsing requires a bit of evaluating the dataset and identifying where your data is located. nodes, text and comment etc). Thus: The XmlReader retains more complexity. The Broncos have to fill major holes on offense this season, but the defense should. xml-commons is an unusual project in several ways. In my last blog we discussed on JSON format file parsing in Apache Spark. 0) capabilities are available. parser is an optional parser instance. First of all you should create metadata of your XML file, but in this post I am using XSD to populate source schema in tXMLMap. json Does not really work for me. If you are new in working with XML in AS400 or just starting to do some XML parsing, this article will be useful to you. Click Use the XML Source task pane. Net Hadoop MapReduce Job Submission” code one of the goals was to support XML file processing. data How to parse nested JSON objects in spark sql? spark write nested json (3) I have a schema as shown below. Several key methods and properties in JavaScript can help in getting information from an XML file. Here’s the xml file I’m parsing. 1, but the one " unsupported " feature I always test first is " Nested Virtualization " (aka Nested ESXi) and with the latest release, it seems to have gotten even better. Read more here:: WP All Import: Import nested custom taxonomies. Now that I am more familiar with the API, I can describe an easier way to access such data, using the explode() function. With SHORTREF you declare text tokens to be replaced into other text (typically start- and end-element tags). Changed in version 3. The XML DOM (Document Object Model) defines the properties and methods for accessing and editing XML. parse() to parse a json string to an object,but the object has garbled. There are many solutions for parsing XML data into hive table. October 15, 2015 How To Parse and Convert JSON to CSV using Python May 20, 2016 How To Parse and Convert XML to CSV using Python November 3, 2015 Use JSPDF for Exporting Data HTML as PDF in 5 Easy Steps July 29, 2015 How To Manage SSH Keys Using Ansible August 26, 2015 How To Write Spark Applications in Python. There are several ways of doing this, and the Digester component was designed to provide a common implementation that can be used in many different projects. This project welcomes contributors. END-XML permits a conditional XML GENERATE or XML PARSE statement (that is, an XML GENERATE or XML PARSE statement that specifies the ON EXCEPTION or NOT ON EXCEPTION phrase) to be nested in another conditional statement. 2, in its Scala API, and I have pretty big XML Files in a Local File System (10GB). xml') in server location 'MYDIR' 2) I want to read the xml data and store in to DB table 3) I am using 'BFILENAME' utility to load the xml data in to 'BFILE' and using 'dbms_xmlparser' utility to parsing the xml data. Nested types will then be evalulated. order denotes the order in which node and edge elements occur in the document. To process the data contained in XML documents, you need to write a application program (in a programming language such as Java, JavaScript). If you know the structure of your JSON objects, you can create custom. Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. This issue can happen when either creating a DataFrame using: val people = sqlContext. Graph stores are used to store information about networks of data, such as social connections. Get the Value of an Element. At the outset, it. Any how I wrote a few articles about this topic a few weeks ago and also published source code for doing the conversion. Following is a step-by-step process to load data from JSON file and execute SQL query on the loaded data from JSON file: Create a Spark Session. I tried doing it myself but quickly got confused and couldn't make progress. XML is a complex format as it is a tree structure, but with a XSD it is possible to safely convert the XML file. SSIS XML Parser Transform can parse XML string into multiple columns and rows (Helpful to extract data from raw XML string stored as database column or coming from other source). To facilitate the nesting of child objects when a DataSet is synchronized with an XmlDataDocument or written as XML data using WriteXml, the DataRelation exposes a Nested property. Convert Java Objects to XML and XML to Java Objects with XStream Learn how to convert XML objects to Java, and vice versa. This opinionated guide exists to provide both novice and expert Python developers a best practice handbook to the installation, configuration, and usage of Python on a. databricks:spark-xml_2. The tree knows about all of the data in the input. In Part 2 of this article series, Accessing Database Data, we looked at how to use the SqlDataSource control to retrieve data from a relational database, which could then be bound to any data Web control (such as the GridView. After all data has been sorted, we are ready to create joins. One of the benefits of using nested FOR XML queries is that you can specify a combination of attribute-centric and element-centric XML for query results. Easily create stunning social graphics, short videos, and web pages that make you stand out on social and beyond. The XML is generated by a third party document. Maciek Kocon September 8, 2016 Big Data , Spark , XML Note: We have written an updated version of this post that shows XML conversion on Spark to Parquet with code samples. DOM parser parses the entire XML document and loads it into memory; then models it in a “TREE” structure for easy traversal or manipulation. It will also create appropriate IDs so nodes can be linked. Complex and Nested Data — Databricks Documentation View Azure Databricks documentation Azure docs. Count returned 12 tables). Use Nested FOR XML Queries. In order to use Spark date functions, Date string should comply with Spark DateType format which is 'yyyy-MM-dd'. Microsoft Scripting Guy, Ed Wilson, is here. For example lets say I want to be able to call Astros nested in the Baseball array and have it print out the accompanying information on the line there so I want to be able to access and spit out "Astros:. uncacheTable("tableName") to remove the table from memory. For complex XML files at large volumes it's better to use a more robust tool. any sample code will be much helpful. In this tutorial, we will show you how to read an XML file via DOM XML parser. Is there any way to map attribute with NAME and PVAL as value to Columns in dataframe?. Thanks for your understanding. text is a string containing XML data. png Now, how to extract all data in. The structure and test tools are mostly copied from CSV Data Source for Spark. Element nodes do not have a text value. Reading an XML file means that we are reading the information embedded in XML tags in an XML file. Child elements can very in their types, meaning you can have a number of different child elements under a single parent element. The MongoDB BSON implementation is lightweight, fast and highly traversable. The complete class diagram is shown in Figure 1. How to parse the nested xml elememt in java? If this is your first visit, be sure to check out the FAQ by clicking the link above. I wanted to parse the file and filter out few records and write output back as file. SELECT or Query nodes in hierarchial or nested XML. 3: This module will use a fast implementation whenever available. Why I prefer SAX to parse XML. My documents schema are uniform with in an index type. 9 through RSS 1. 2, in its Scala API, and I have pretty big XML Files in a Local File System (10GB). Use these instructions to install Java software on your desktop. In the code snippet above we can see how the stream reader is configured. i will develop one software for that i need one solution that is i have xml file with country,state. How to parse JSON string in Python Last updated on May 16, 2013 Authored by Dan Nanni 2 Comments When developing a web service, you may often rely on a JSON-based web service protocol. So I am trying to utilize specifying the schema while. It analyses the XSD, creates an optimised target schema, processes the XML,. So when I see the schema, It is having complex nesting. Apache Spark Packages, from XML to JSON. %md Let ' s create a simple JSON schema with attributes and values,. However, these have various disadvantages which I have listed below, e. I need to parse specific tags from an xml document (Microsoft Word docx document. Since the whole XML document is not loaded into memory, such an application can be less memory-intensive in contast to using a DOM-based approach. Hello everyone I have an XML file which is a multitable nested xml file (. So, in order to obtain the float value 36. Another solution is to store XML files as a single string data into a hive temp table and then fetch the data of each tag using XPATH. Each listitem will have sub text content for displaying mutiple text. Another important aspect of LINQ to XML is querying the contents of an XML document. The easiest approach would be using XSD. My documents schema are uniform with in an index type. Study Record Tabs. I need to read this xml using linq to xml concept. find method but it ignores the child parent relation Parsing Nested Repeating XML using JQuery - jQuery Forum. The XML data is opened as read-only in Excel so that you don't accidentally save your original source file in the Excel Macro-Enabled Workbook file format (. In the final column discussing XML conversion in PowerShell, Jeffrey walks you through converting nested objects to XML. Also updating the listview with parsed xml data. Many people working with different kinds of data come across the problem that they need to convert between different data formats. Then we save theRDD as a plain text file. val xmlmodified = data. Complex XML dialplans are sometimes difficult to read and understand, which is why other dialplan processors are available. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. Every Time We parse Xml for various purpose. HibernateException: Could not parse configuration: hibernate. properties' and we call the Properties object's loadFromXML method rather than its load method. The Apache™ Hadoop® project develops open-source software for reliable, scalable, distributed computing. When applying the toJSON function to the DataFrame, we get anRDD[String] with the JSON representation of our data. HI Folks, I am working with a JSON file which has a nested array and I need to be able to call a line of information from each topic, soccer/football/baseball. com alvin alexander. I figured out how to grab individual values and such, but I'm not sure what is the best way to grab a value in relation to where it is in the XML. Handling nested objects. This site uses cookies for analytics, personalized content and ads. xmltodict also lets you roundtrip back to XML with the unparse function, has a streaming mode suitable for handling files that don't fit in memory, and supports XML namespaces. Below is a sample code which helps to do the same. How to parse Nested XML using the SAX parser. XML data is represented in Scala either by a generic data representation or data-specific data representation. Below is a sample code which helps to do the same. This is a simple class that can parse an XML document and return a nested associative array with the document tag structure. which will contain: 1. com alvin alexander. Eatonville native Ha Ha Clinton-Dix helped spark the Chicago Bears’ 31-15 win over the Washington Redskins in the national spotlight Monday night. This is an excerpt from the Scala Cookbook (partially modified for the internet). Next, we will add the Customers. Basically she tested the same job in Hive (exploding multiple arrays) and PySpark dataframes using the spark-xml lib. However, it has various disadvantages which I have listed below, e. Sample XMl file with Nested Loops. The last blog post that I did focused on creating an XML document using LINQ to XML. The input to this code is a csv file which contains 3 columns. Many projects read XML configuration files to provide initialization of various Java objects within the system. How to read and write JSON files with Spark I wanted to build a Spark program that would read text file where every line in the file was a Complex JSON object like this. XML Processing in Scala. Key-value stores are the simplest NoSQL databases. Nested loop join is often defined as the most basic joining algorithm in SQL. m , or use the parseXML. 2) Convert XML String to Java Object. Comma Separated Values (CSV) File format - Creativyst, Inc. Reading JSON-Formatted Data With JsonLoader. Before deep diving into this further lets understand few points regarding…. Learn how to work with Apache Spark DataFrames using Python in Databricks. As you can appreciate, our success comes in the form of a loyal client base. I am implementing a class that should receive a large text fileI want to split it in chunks and each chunk to be hold by a different thread that will count the frequency of each character in this chunk. a list of valid automobile colors. The animal_interpretation column has a StructType type — this DataFrame has a nested schema. It is written in Scala, runs on Spark, and it’s fast. Create a parsing function to read an XML file into a MATLAB® structure, and then read a sample XML file into the MATLAB workspace. In this blog post, we introduce Spark SQL’s JSON support, a feature we have been working on at Databricks to make it dramatically easier to query and create JSON data in Spark. Right click and create new XML file. If your XML file has lots of nested tags, you may want to use an XML viewer instead. Metadata creation Go to File XML under Metadata. Solved: Hi I am trying to parse the below xml file , I need the relation name and table name from the below , I have tried using XML Parse but could JavaScript must be installed and enabled to use these boards. Convert XML to JSON with JavaScript to work with the JSON format instead of the XML format. One is using native Hive JSON function such as get_json_object and the other is to use a JSON Serde to parse JSON objects containing nested elements with lesser code. Here is the requirement for our XML file. 0's modules, RSS 2. I'm using the attached c# code to parse the attached xml file. Now, we could use Drill to read and query our new dataset and of course, we can always go back to Spark if we need to do something more complicated operations / transformations. My idea is to convert the XML to JSON using python, in the same python input script that we have scheduled to import the data. Hope this helps. Solved: Hi Guys, We have a use cases to parse XML files using Spark RDD. Create Document object from xml file. Next, data must be sorted. The XML could be in a file or XML could be a string. So let's assume the query is nested like. A nested class has access to the members. As you upload XML file and click CONVERT, the program delivers high-quality output in a new format. The XML data is opened as read-only in Excel so that you don't accidentally save your original source file in the Excel Macro-Enabled Workbook file format (. In most cases, you don’t have to go multiple levels deep, but it can entirely depend on the data set being represented by the XML. the problem is how to create reference between Stations and CAR tables in the dataset? or is there other load nested xml to dataset vb. val xmlmodified = data. The scope of a conditional XML GENERATE or XML PARSE statement can be terminated by:. The list will be evaluated first. My goal is to read each element and, do some transformation and convert it to Json , but the result should be similar to the XML I have provided. About 100 ways to extract data from XML nodes in Scala, including methods like child and text, and XPath expressions. So I decided to convert it to json and then to xml. How to read this table into an RDD, and more importantly how to filter, map etc this nested collection in Spark?. In this case ‘smil’ is an XML Element, ‘head’ and ‘body’ is are also XML elements, but they are children of smil (or child nodes). If you click on DEPTNAME or DEPTNO we have to list out the employees in the corresponding department. (9 replies) hi guys, i'm looking for tutorials on how i can parse nested xml tags using sax parser but i can't find a right solution for my case. We can query all the data but if you want to run a query with where clause against the columns first-name, last-name and middle-name,the query wont work as those columns contains hypen in it. Another important aspect of LINQ to XML is querying the contents of an XML document. Parsing XML We have created parseXML() function to parse XML file. In this article, let us see how to extract data from XML in Java. Use XmlObject. cannot resolve explode due to type mismatch in spark while parsing xml file. I covered lxml’s etree and Python’s included minidom XML parsing library. 0, and Atom. Source XML has list of Items from a retail store, and node repeated for each item. NET MVC by SSWUG Research (Rajitha Alluri) In this article, we will learn how to parse XML having nested nodes in C#.