locked
How to get data from NHibernate XML mapping file RRS feed

  • Question

  • How would you get values from a NHibernate XML mapping file?  I am using C# and preferably linq

    I have files that have for example:

    <root>

    <class table="tablename" name="name">

    <many-to-one name="name" column="column">

    <many-to-one name="name" column="column">

    <many-to-one name="name" column="column">

    <many-to-one name="name" column="column">

    What I need is to be able to get the values of the many-to-one names and columns.  I know that there will be a foreach loop, but that is as far as I get.

    Wednesday, March 14, 2012 5:46 AM

Answers

  • The way I was able to do it was a little different then a regular xml document.  after loading the xml document I used the following: (using a variation of childrennodes and ect. to get specifics)

    XmlDocument doc = new XmlDocument(); doc.load("file"); string className = doc.DocumentElement.FirstChild.Attributes.Item(1).Value.ToString();

    // second example looping within a loop

    string relation;

    relation = doc.DocumentElement.FirstChild.ChildNodes.Item(b).ChildNodes.Item(d).ChildNodes.Item(1).Name.ToString();

    • Marked as answer by sdprest Wednesday, April 4, 2012 11:43 PM
    Wednesday, April 4, 2012 11:42 PM

All replies