1

I have a below query in C# getting data from oracle

 using (OracleConnection con = new OracleConnection(ConnectionString))
    {
        con.Open();
     OracleCommand command = new OracleCommand("select firstname,secondname,lastname,
age,gender from Members", con))
     OracleDataReader rdr = command.ExecuteReader();
    while(rdr.Read())
    {
    .....
    } 

    }

Now from this query i need to create an xml as below. Please help me to know the best way to achieve the same

<Root>
<Member>
<Name>
  <firstname>firstname1<firstname>
  <secondname>secondname1<secondname>
  <lastname>lastname<lastname>
</Name>
<age>45</age>
<gender>M</gender>
</Member>
<Member>
<Name>
  <firstname>firstname2<firstname>
  <secondname>secondname2<secondname>
  <lastname>lastname2<lastname>
</Name>
<age>25</age>
<gender>F</gender>
</Member>
</Root>

1 Answer 1

1

First method .Use XmlElement,XMLAttributes, XMLForest... for selected items, for additional information please open link below

https://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb13gen.htm#ADXDB4994

Second method. You can read query result and after that try serialize an object to XML

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.