Question: If I add dynamic\_sidebar() to theme and in admin panel insert menu widget in this, wp generates such a structure:

```
<div id="nav_menu" class="widget widget_nav_menu">
    <div class="menu-container">
        <ul id="menu" class="menu">
            <li id="#" class="menu-item">
                <a href="#">Item 1</a>
            </li>
            <li id="#" class="menu-item">
                <a href="#">Item 2</a>
            </li>
            <li id="#" class="menu-item">
                <a href="#">Item 3</a>
            </li>
        </ul>
    </div>
</div>

```

How to change the container to nav?
And I want to add Shema like this

```
<div id="nav_menu" class="widget widget_nav_menu" itemscope itemtype="http://www.schema.org/SiteNavigationElement">
    <nav class="menu-container">
        <ul id="menu" class="menu">
            <li id="#" class="menu-item" itemprop="name">
                <a href="#" itemprop="url">Item 1</a>
            </li>
            <li id="#" class="menu-item" itemprop="name">
                <a href="#" itemprop="url">Item 2</a>
            </li>
            <li id="#" class="menu-item" itemprop="name">
                <a href="#" itemprop="url">Item 3</a>
            </li>
        </ul>
    </nav>
</div>

```

Thanks for answer)

Answer: 
To change the menu container please use the filter hook `wp_nav_menu_args`

**Paste the below code in current active theme functions.php file**

```
function my_nav_menu_args( $args = '' ) {

       if( 'primary' == $args['theme_location'] )
       {
          if ( $args['container'] == 'div' ) {
              $args['container'] = 'nav';
          }
        }

        return $args;
    }

    add_filter( 'wp_nav_menu_args', 'my_nav_menu_args' );

```

For more help : [click Here](https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_nav_menu_args)
You can replace tags with pregreplace.

```
function change_submenu_class($menu) {  
  $menu = preg_replace('/<div id="nav_menu" class="widget widget_nav_menu">/','/<div id="nav_menu" class="widget widget_nav_menu" itemscope itemtype="http://www.schema.org/SiteNavigationElement">/',$menu);  
  return $menu;  
}  
add_filter('wp_nav_menu','change_submenu_class');

```

and same pregreplace function for li and other tags you want to change.