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 Administrator
    Staff Member

    United States
    Aug 7, 2010
    Likes Received:
    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=" " xmlns:xbrli=" " xmlns:link=" "
    xmlns:xlink=" " xmlns:nflx=" " xmlns:xbrldt=" "
    targetNamespace=" " elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:num=" "
    xmlns:nonnum=" " xmlns:us-types=" " xmlns:invest="

    When I look at elements in the xdocument, I can always retrieve the correct namespace no problem: e.g.
    <link:roleType roleURI=" " id= "StatementConsolidatedBalanceSheets
    "<a> doc1.Root.Elements.ElementAt(0).Name.NamespaceName" returns: 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