can somebody give me an explanation why a book use the term section instead of element

T

Tony Johansson

Hello!

Here is some text from the book.
"The following code snippet shows an example of a configuration file that
includes both an appSettings and a connectionStrings section."
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Foo" value="Hello World""/>
</appSettings>
<connectionStrings>
<clear/>
<add name="AdventureWorksString"
providerName="System.Data.SqlClient"
connectionString="Data Source=localhost;
Initial Catalog=AdventureWorks; Integrated Security=true" />
</connectionStrings>
</configuration>

Now to my question why do they use the term section when they should use the
term element ?

//Tony
 
J

Jeff Johnson

Tony Johansson said:
Hello!

Here is some text from the book.
"The following code snippet shows an example of a configuration file that
includes both an appSettings and a connectionStrings section."
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Foo" value="Hello World""/>
</appSettings>
<connectionStrings>
<clear/>
<add name="AdventureWorksString"
providerName="System.Data.SqlClient"
connectionString="Data Source=localhost;
Initial Catalog=AdventureWorks; Integrated Security=true" />
</connectionStrings>
</configuration>

Now to my question why do they use the term section when they should use
the term element ?

Every direct child of the <configuration> element must have a piece of code
that handles reading the contents of that element. I don't know if this is
the official term, but that code can be thought of as a "section handler."
There are several handlers built in to the .NET Framework, such as the ones
that handle the <appSettings> block and the <connectionStrings> block. You
can create your own by deriving from
System.Configuration.ConfigurationSection.

Simply put, "section" is Microsoft's term for the immediate children of the
<configuration> element in an app.config file. <connectionStrings> itself is
an element, yes, in the strict XML sense. <connectionStrings> and everything
inside it, in the context of an app.config file, is also a "section."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top