namespaces not found while reading attributes in an Xelement

Discussion in 'Database, XML and Reporting' started by DN Admin, Mar 14, 2012.

  1. DN Admin

    DN Admin
    Expand Collapse
    Staff Member

    Country:
    United States
    Joined:
    Aug 7, 2010
    Likes Received:
    258
    Trophy Points:
    45
    Location:
    Joliet, IL U.S.A.
    I am reading an xml doc in an Xdocument. There are several namespaces declared in the root node:
    <schema xmlns=" http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema " xmlns:xbrli=" http://www.xbrl.org/2003/instance http://www.xbrl.org/2003/instance " xmlns:link=" http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/linkbase "
    xmlns:xlink=" http://www.w3.org/1999/xlink http://www.w3.org/1999/xlink " xmlns:nflx=" http://www.netflix.com/20111231 http://www.netflix.com/20111231 " xmlns:xbrldt=" http://xbrl.org/2005/xbrldt http://xbrl.org/2005/xbrldt "
    targetNamespace=" http://www.netflix.com/20111231 http://www.netflix.com/20111231 " elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:num=" http://www.xbrl.org/dtr/type/numeric http://www.xbrl.org/dtr/type/numeric "
    xmlns:nonnum=" http://www.xbrl.org/dtr/type/non-numeric http://www.xbrl.org/dtr/type/non-numeric " xmlns:us-types=" http://fasb.org/us-types/2011-01-31 http://fasb.org/us-types/2011-01-31 " xmlns:invest=" http://xbrl.sec.gov/invest/2011-01-31 http://xbrl.sec.gov/invest/2011-01-31

    When I look at elements in the xdocument, I can always retrieve the correct namespace no problem: e.g.
    <link:roleType roleURI=" http://www.netflix.com/role/StatementConsolidatedBalanceSheets http://www.netflix.com/role/StatementConsolidatedBalanceSheets " id= "StatementConsolidatedBalanceSheets
    "<a> doc1.Root.Elements.ElementAt(0).Name.NamespaceName" returns:
    http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/linkbase as expected.

    BUT when I do the same for an ATTRIBUTE in an element, I always get nothing, regardless of whether there is a prefix or not: e.g.
    <element id="ContentLibraryNetCurrent" name="ContentLibraryNetCurrent" nillable="true" type="xbrli:monetaryItemType" substitutionGroup="xbrli:item" xbrli:periodType="instant" xbrli:balance="debit" />

    "Element.Attributes.ElementAt(0).Name.NamespaceName" (no prefix) returns an empty string<br/>
    "Element.Attributes.ElementAt(3).Name.NamespaceName" (prefix is xbrli) also returns an empty string

    Anyone know what's up?<span style="color:#008000; font-size:small <span style="color:#008000; font-size:small <span style="color:#008000; font-size:small

    View the full article
     

Share This Page