Note that there are some explanatory texts on larger screens.

plurals
  1. POFind Node from XML and Convert to Class
    primarykey
    data
    text
    <p>This is my XML schema,</p> <pre><code>&lt;Modules&gt; &lt;Module name="Sales" path="../SalesInfo.xml" isEnabled="true" ... &gt; .............. &lt;/Module&gt; &lt;Module name="Purchase" path="../PurchaseInfo.xml" isEnabled="true" ... &gt; .............. &lt;/Module&gt; ................ &lt;/Module&gt; &lt;/Modules&gt; </code></pre> <p><strong>SalesInfo.XML</strong></p> <pre><code> &lt;Screens&gt; &lt;Screen name="SalesOrder" ........ /&gt; &lt;/Screen&gt; public class Module { public string Name { get; set; } public string Type { get; set; } ..... } </code></pre> <p>Here the modules and Screens are loaded on Request basis ("On Demand"). So i have to find the particular node when request comes(may be from menu click). Once the node is picked, it need to be converted to particular class. Eg when "sales" request comes, it should picked from XML and that need to converted to "Module" class. As one possible way is </p> <ul> <li>Using XPathNavigator and find the Node.</li> <li>Parse the "Finded Node" and convert to Particular class</li> </ul> <p>This is bit complicated. I have to take care of all the attribute and its datatypes.</p> <p><strong>What i looking for</strong></p> <ul> <li>Find the Node</li> <li>Convert the Node to My custom Class (I doesn't want to write code for Parser)</li> </ul> <p>What is the Best approach. I'm working on C# 4.0.</p> <p><strong>EDIT:</strong></p> <pre><code>XDocument document = XDocument.Load(path); XElement mod = document.XPathSelectElement("Modules/Module[@name='PurchaseEnquiry']") as XElement; Module purchaseModule = mod as Module; //This won't work, but i want like this. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload