Reputation: 121
my language is asp.net. and I use Linq to parsing xml file. but this xml file have set namespace. before load xml file. I try to import xml namespace. but still can't parsing xml correctly.
Imports <xmlns="abc">
<html>
<head>
<title>Do-Life</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../../img/css.css" rel="stylesheet" type="text/css">
<script runat="server">
Sub Page_Load(ByVal sender as Object, ByVal e as System.EventArgs)
If not isPostBack Then
....
Dim TYPINFO As XElement = XElement.Load(server.MapPath(filename))
Dim tinfos As IEnumerable(Of XElement)
tinfos = From tf In TYPINFO...<typhinfo> Select tf
....
....
xml file:
<?xml version="1.0" encoding="UTF-8"?>
<cwbtyphfcst xmlns="abc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cwb.wfc.typhoonfcstCE/namespace typhooninfor.xsd">
<announcement>
...
Upvotes: 0
Views: 424
Reputation: 121
I have know the issue.
If I modify the xml content as
<?xml version="1.0" encoding="UTF-8"?>
<cwbtyphfcst xmlns:ns="abc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cwb.wfc.typhoonfcstCE/namespace typhooninfor.xsd">
<announcement>
...
identify the namespace prefix name as "ns"
and import the namespace as
Imports <xmlns:ns="abc">
finally, linq is work everything.
Upvotes: 1