0

私の言語はasp.netです。そして、Linq を使用して xml ファイルを解析します。しかし、このxmlファイルには名前空間が設定されています。xml ファイルをロードする前に。xml 名前空間をインポートしようとしています。しかし、まだxmlを正しく解析できません。

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 ファイル:

<?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>
    ...
4

1 に答える 1

1

私は問題を知っています。

xmlコンテンツを次のように変更すると

<?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>
...

名前空間プレフィックス名を「ns」として識別します

名前空間を次のようにインポートします

Imports <xmlns:ns="abc">

最後に、linq はすべての作業です。

于 2013-02-19T01:27:30.073 に答える