Sunday, 15 June 2014

vb.net - use Linq to parsing xml , import namespace. still can't read xml currectly, WHY? -



vb.net - use Linq to parsing xml , import namespace. still can't read xml currectly, WHY? -

my language asp.net. , utilize linq parsing xml file. xml file have set namespace. before load xml file. seek import xml namespace. still cant 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 object, byval e system.eventargs) if not ispostback .... dim typinfo xelement = xelement.load(server.mappath(filename)) dim tinfos ienumerable(of xelement) tinfos = 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> ...

i have know issue.

if modify xml content

<?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 namespace prefix name "ns"

and import namespace as

imports <xmlns:ns="abc">

finally, linq work everything.

xml vb.net linq xml-namespaces

No comments:

Post a Comment