XPath
Informationen
- Kategorien: Kernel | Klassenformeln
- Version: 15.0.0.3282
- Veröffentlichungsdatum: Dienstag, 15. November 2011
- Entwickler: Schulze
- Benötigt Datenbankänderung: Nein
- Betreff: XPath Queries
Beschreibung
2 neue Funktionen für XPath-Abfragen:
- XmlSelectNodeValues
- XmlSelectNodeHandles
=> XPath Version 1.0 (mit MSXML 4.0)
Beispieldaten (siehe http://www.w3schools.com/xpath/xpath_examples.asp):
======================= Inhalt von xpath.txt:
z.B. Elementabfrage /bookstore/book/title
oder Attributabfrage /bookstore/book/@content
======================= Inhalt von content.xml:
Beispielcode
oncallfunction
{
var string $sXmlFile;
var string $sXPathFile;
var string $sXPath;
var string $arrNodes[];
var int $arrHandles[];
var string $sText;
var string $sValue;
var int $nHandle;
var int $i;
var int $bResult;
var string $sError;
$sXmlFile = "E:\\xmltest\\content.xml";
$sXPathFile = "E:\\xmltest\\xpath.txt";
$sXPath = ReadTextFile( $sXPathFile );
XmlLoadFromFile( $sXmlFile );
$bResult = XmlSelectNodeValues( $sXPath, $arrNodes, $sError );
if( !$bResult )
{
MessageBox( $sError );
return;
}
$bResult = XmlSelectNodeHandles( $sXPath, $arrHandles, $sError );
if( !$bResult )
{
MessageBox( $sError );
return;
}
$sText =
"XPath=" + $sXPath + "\n" +
"Xml=" + XmlStoreToString() + "\n" +
"XPath Nodes:\n";
$i = 0;
while ( $i < GetSize( $arrNodes ) )
{
$sValue = "";
$nHandle = -1;
if ( GetSize( $arrHandles ) > 0 )
{
$nHandle = $arrHandles[ $i ];
XmlGetNodeValue( $arrHandles[ $i ], $sValue );
}
$sText = $sText + $arrNodes[ $i ] +
" Handle=" + IntToStr( $nHandle ) +
" ValueByHandle=" + $sValue + "\n";
$i = $i + 1;
}
XmlCloseDocument();
MessageBox( $sText );
}