菜鸟求一段xpath怎么写啊?
<?xml version="1.0" encoding="gb2312" ?>
<root>
<layers>
<layer>
<layername>集体食堂</layername>
<Editable>true</Editable>
<Table>集体食堂</Table>
<Related>true</Related>
<RelationTable>集体食堂_属性</RelationTable>
<showField>申请单位</showField>
<RelationField>许可证号</RelationField>
<RelatedField>许可证号</RelatedField>
</layer>
<layer>
<layername>门牌</layername>
<Editable>true</Editable>
<Table>门牌</Table>
<Related>true</Related>
<RelationTable>门牌_属性</RelationTable>
<showField>门牌号</showField>
<RelationField>门牌号</RelationField>
<RelatedField>门牌号</RelatedField>
</layer>
</layers>
</root>
问我如何求得 editalble 为TRUE的 layer节点列表.
并且我获得这个节点nodeslist 如何取得每个节点的子节点的layername的值呢?
[解决办法]
<%set parser=Server.CreateObject("MSXML2.DOMDocument")parser.async=falseparser.load(Server.MapPath("1.xml"))if parser.parseError.errorCode<>0 then s="Error on line "&parser.parseError.Line&vbCrLf s=s&parser.parseError.srcText &vbCrLf s=s&Space(parser.parseError.linepos) s=s&"---"&parser.parseError.reason MsgBox send ifset strE=parser.selectNodes("//layer/Editable[.='true']") if Not strE is Nothing then for i=0 to strE.length-1 set layE=strE.item(i).previousSibling Response.Write layE.firstChild.nodeValue&"<br/>" next end if %>
[解决办法]
可以参考一下这篇:http://blog.csdn.net/cds27/archive/2008/04/18/2305166.aspx
[解决办法]
<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output method="html" indent="yes"/> <xsl:template match="//root"> <xsl:for-each select ="//layer[Editable='true ']"> <xsl:value-of select ="layername"/> </xsl:for-each> </xsl:template></xsl:stylesheet>
[解决办法]
//layer[Editable="true"]