views:

113

answers:

1

I use xml to get label for my website.

the xml generated from database file look like this

<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly' rs:updatable='true'>
    <s:AttributeType name='LABEL_KEY' rs:number='1' rs:nullable='true'>
        <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='1000'/>
    </s:AttributeType>
    <s:AttributeType name='Label_LNG' rs:number='2' rs:writeunknown='true' rs:basecatalog='1500_GoldenFlour' rs:basetable='t_Label_SITE_PER_LNG'
         rs:basecolumn='Label_LNG'>
        <s:datatype dt:type='string' dt:maxLength='4000' rs:maybenull='false'/>
    </s:AttributeType>
    <s:AttributeType name='Label_ID' rs:number='3' rs:basecatalog='1500_GoldenFlour' rs:basetable='t_Label_SITE'
         rs:basecolumn='Label_ID' rs:keycolumn='true' rs:hidden='true' rs:autoincrement='true'>
        <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>
    </s:AttributeType>
    <s:AttributeType name='c3' rs:name='Label_ID' rs:number='4' rs:writeunknown='true' rs:basecatalog='1500_GoldenFlour'
         rs:basetable='t_Label_SITE_PER_LNG' rs:basecolumn='Label_ID' rs:keycolumn='true' rs:hidden='true'>
        <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>
    </s:AttributeType>
    <s:AttributeType name='Language_ID' rs:number='5' rs:writeunknown='true' rs:basecatalog='1500_GoldenFlour'
         rs:basetable='t_Label_SITE_PER_LNG' rs:basecolumn='Language_ID' rs:keycolumn='true' rs:hidden='true'>
        <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>
    </s:AttributeType>
    <s:extends type='rs:rowbase'/>
</s:ElementType>
</s:Schema>
<rs:data>
    <z:row LABEL_KEY='_home' Label_LNG='Home' Label_ID='1' c3='1' Language_ID='1'/>
<z:row LABEL_KEY='_members_area' Label_LNG='Members Area' Label_ID='2' c3='2' Language_ID='1'/>
<z:row LABEL_KEY='_logout_members_area' Label_LNG='Logout Members Area' Label_ID='3' c3='3' Language_ID='1'/>
<z:row LABEL_KEY='_site_map' Label_LNG='Site Map' Label_ID='4' c3='4' Language_ID='1'/>
</rs:data>
</xml>

my function is

    Public Function Get_Item(Temp_L_KEY)
        Set XMLL = Server.CreateObject("MSXML2.DOMDocument.4.0") 
        XMLL.Async = False
        XMLL.Load (Server.MapPath(Replace(application("root"),"/","\") & "system\db\dict\SITE_xml_" & Temp_LNG_ID & ".xml"))
        Get_Item=xmll.selectSingleNode("xml/rs:data/z:row[@LABEL_KEY='" & lcase(Temp_L_KEY) & "']").attributes(1).value
            if err.number <>0 then
                Get_Item=Temp_L_KEY
            end if
    End Function

and i get that error

msxml4.dll error '80004005'

Reference to undeclared namespace prefix: 'rs'.
+3  A: 

You have not declared any namespaces for MSXml.

You can add the following after loading the document and before selection:

XMLL.setProperty("SelectionNamespaces", "xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset'");

See this article for more details.

Oded
great,now i get Microsoft VBScript runtime error '800a01a8'Object required: 'XMLL.selectSingleNode(...)'
eyalb
@eyalb - Guess the Xpath query returned no results, or you are accessing attributes that do not exist.
Oded