Try
Dim xmlDOC As New XmlDocument()
xmlDOC.Load(XMLFILE)
Dim nodeList As XmlNodeList = xmlDOC.SelectNodes("/Report/DataSets/DataSet")
MsgBox(nodeList.Count)
For Each node As XmlNode In nodeList
MsgBox("DataSet Name: " & node("Name").InnerText)
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
ASKER
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
</Report>
You'll have to define (and use) a namespace manager, and you'll have to add a prefix to the xpath default elements (that don't have an explicit one in the document).$xmlDoc = [System.Xml.XmlDocument]::New()
$xmlDoc.Load("C:\Temp\Report.rdlc")
$nsMgr = [System.Xml.XmlNamespaceManager]::New($xmlDoc.NameTable)
$nsMgr.AddNamespace("ns", $xmlDoc.Report.GetAttribute("xmlns"))
$nsMgr.AddNamespace("rd", $xmlDoc.Report.GetAttribute("xmlns:rd"))
$nodeList = $xmlDoc.SelectNodes("ns:Report/ns:DataSets/ns:DataSet", $nsMgr)
ForEach ($node In $nodeList) {
"DataSet Name: " + $node.GetAttribute("Name")
}
Note: to access, for example, the "DataSourceID" node (note the explicit "rd" namespace), the XPath would look like this:$xmlDoc.SelectNodes("ns:Report/ns:DataSources/ns:DataSource/rd:DataSourceID", $nsMgr)
ASKER
Dim xmlDOC As New XmlDocument()
xmlDOC.Load(XMLFILE)
Dim nsMgr As XmlNamespaceManager = New XmlNamespaceManager(xmlDOC.NameTable)
nsMgr.AddNamespace("ns", "xmlns")
nsMgr.AddNamespace("rd", "xmlns:rd")
Dim nodeList As XmlNodeList = xmlDOC.SelectNodes("ns:Report/ns:DataSets/ns:DataSet", nsMgr)
MsgBox(nodeList.Count)
For Each node As XmlNode In nodeList
MsgBox("DataSet Name: " & node("Name").InnerText)
Next
ASKER
ASKER
PS C:\> $xmlDoc = [System.Xml.XmlDocument]::New()
PS C:\> $xmlDoc.Load("C:\Temp\Report.rdlc")
PS C:\>
PS C:\> $nsMgr = [System.Xml.XmlNamespaceManager]::New($xmlDoc.NameTable)
PS C:\> $nsMgr.AddNamespace("ns", $xmlDoc.Report.GetAttribute("xmlns"))
PS C:\> $nsMgr.AddNamespace("rd", $xmlDoc.Report.GetAttribute("xmlns:rd"))
PS C:\>
PS C:\> $nodeList = $xmlDoc.SelectNodes("ns:Report/ns:DataSets/ns:DataSet", $nsMgr)
PS C:\> ForEach ($node In $nodeList) {
>> "DataSet Name: " + $node.GetAttribute("Name")
>> }
DataSet Name: Sales
PS C:\>
ASKER
ASKER
ASKER
nsMgr.AddNamespace("ns", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition")
nsMgr.AddNamespace("rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner")
ASKER
Dim xmlDOC As New XmlDocument()
xmlDOC.Load(XMLFILE)
Dim nsMgr As XmlNamespaceManager = New XmlNamespaceManager(xmlDOC.NameTable)
nsMgr.AddNamespace("ns", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition")
nsMgr.AddNamespace("rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner")
Dim nodeList As XmlNodeList = xmlDOC.SelectNodes("ns:Report/ns:DataSets/rd:DataSet", nsMgr)
MsgBox(nodeList.Count)
For Each node As XmlNode In nodeList
MsgBox("DataSet Name: " & node("Name").InnerText)
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
MsgBox("DataSet Name: " & node.GetAttribute("Name")
ASKER
Dim xmlDOC As New XmlDocument()
xmlDOC.Load(XMLFILE)
Dim nsMgr As XmlNamespaceManager = New XmlNamespaceManager(xmlDOC.NameTable)
nsMgr.AddNamespace("ns", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition")
nsMgr.AddNamespace("rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner")
Dim nodeList As XmlNodeList = xmlDOC.SelectNodes("ns:Report/ns:DataSets/ns:DataSet", nsMgr)
For Each node As XmlNode In nodeList
MsgBox("DataSet Name: " & node.Attributes.GetNamedItem("Name").ToString)
Next
ASKER
ASKER
Dim xmlDOC As New XmlDocument()
xmlDOC.Load(XMLFILE)
Dim nsMgr As XmlNamespaceManager = New XmlNamespaceManager(xmlDOC.NameTable)
nsMgr.AddNamespace("ns", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition")
nsMgr.AddNamespace("rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner")
Dim nodeList As XmlNodeList = xmlDOC.SelectNodes("ns:Report/ns:DataSets/ns:DataSet", nsMgr)
For Each node As XmlNode In nodeList
MsgBox("DataSet Name: " & node.Attributes("Name").Value)
Dim nodeList_Tables As XmlNodeList = xmlDOC.SelectNodes("ns:Report/ns:DataSets/ns:DataSet/rd:DataSetInfo/rd:TableName", nsMgr)
For Each node_tbl As XmlNode In nodeList_Tables
MsgBox("Table Name: " & node_tbl.Value)
Next
Next
ASKER
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="DataSet1">
<ConnectionProperties>
<DataProvider>System.Data.DataSet</DataProvider>
<ConnectString>/* Local Connection */</ConnectString>
</ConnectionProperties>
<rd:DataSourceID>87380aff-faaf-405d-9335-fada0e622245</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1">
<Query>
<DataSourceName>DataSet1</DataSourceName>
<CommandText>/* Local Query */</CommandText>
</Query>
<Fields>
</Fields>
<rd:DataSetInfo>
<rd:DataSetName>DataSet1</rd:DataSetName>
<rd:SchemaPath></rd:SchemaPath>
<rd:TableName>ScriptSelect</rd:TableName>
<rd:TableAdapterFillMethod>Fill</rd:TableAdapterFillMethod>
<rd:TableAdapterGetDataMethod />
<rd:TableAdapterName>ScriptSelectTableAdapter</rd:TableAdapterName>
</rd:DataSetInfo>
</DataSet>
</DataSets>
<rd:ReportUnitType>Inch</rd:ReportUnitType>
<rd:ReportID>569892cc-4847-403b-a49d-403de0420c11</rd:ReportID>
</Report>
ASKER
Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.
TRUSTED BY