www.webdeveloper.com
Results 1 to 3 of 3

Thread: how to parse through the output of Xpath Query

  1. #1
    Join Date
    Mar 2014
    Posts
    6

    how to parse through the output of Xpath Query

    Code:
    <?php
    
    $variable=$_POST['module'];	
    $xmldoc = new DOMDocument();
            $xmldoc->load('info.xml');
    
            $xpathvar = new Domxpath($xmldoc);
    		
    		$queryResult = $xpathvar->query("testcase[substring-after(
            substring-after(script, '/'),
            '/'
        ) = '$variable' or
        substring-before(
            substring-after(
                substring-after(script, '/'),
                '/'
            ),
            '/'
        ) = '$variable']"); 
    	
    foreach($queryResult as $var)
    		{
                    echo $var->textContent;
    				echo "\n";
    		
    		}
            
    ?>

    I have written this code to fetch those content of xml file where my given condition is satisifed.
    Current my output is like -

    Code:
    DebugLogging_F_05._IPv4_RIP 970249 WIRED scripts/testSuite/hostAgentFeatures/debugLogging/debugLoggingFeatureTesting/Ipv4Rip.tcl This test case verifies that the Debug RIP messages are present in debug log. TCL STC OK 46371 NULL ALL BASELINE RIP ROUTING target:system:family:2510-24,target:system:family:2510-48,target:system:family:2510G,target:system:family:2610,target:system:family:2615,target:system:family:2620,target:system:family:2626,target:system:family:2650,target:system:family:2810,target:system:family:2824,target:system:family:2848,target:system:family:2900,target:system:family:2910,target:system:family:2915,target:system:family:2920,target:system:family:3500,target:system:family:3500jr,target:system:family:3500strk,target:system:family:3800,target:system:family:3800FIPS,target:system:family:4100,target:system:family:4200,target:system:family:5300,target:system:family:5400,target:system:family:5400FIPS,target:system:family:5400R,target:system:family:5400RFIPS,target:system:family:6100,target:system:family:6600,target:system:family:8200,target:system:family:8200FIPS,target:system:family:stack-AR,target:system:family:stack-TA DebugLogging_F_06._IPv4_FIB 987839 WIRED scripts/testSuite/hostAgentFeatures/debugLogging/debugLoggingFeatureTesting/DebugLoggingIPv4FIB.tcl The purpose of this test is to verify that when an FIB messages are generated, the DUT can capture the FIB entries and displays the events properly on debug destination. TCL STC OK 46399 NULL ALL BASELINE target:system:family:2510-24,target:system:family:2510-48,target:system:family:2510G,target:system:family:2610,target:system:family:2615,target:system:family:2620,target:system:family:2626,target:system:family:2650,target:system:family:2810,target:system:family:2824,target:system:family:2848,target:system:family:2900,target:system:family:2910,target:system:family:2915,target:system:family:2920,target:system:family:3500,target:system:family:3500jr,target:system:family:3500strk,target:system:family:4100,target:system:family:4200,target:system:family:5300,target:system:family:5400,target:system:family:5400FIPS,target:system:family:5400R,target:system:family:5400RFIPS,target:system:family:6100,target:system:family:6600,target:system:family:8200,target:system:family:8200FIPS,target:system:family:stack-AR DebugLogging_F_07._IPv6_Packet 1068980 WIRED scripts/testSuite/hostAgentFeatures/debugLogging/debugLoggingFeatureTesting/DebugLoggingIPv6Packet.tcl The purpose of this test is to verify that when ipv6 packet is enabled and there is no connection between the 2 switches, a fail in communication message is entered in the event log. Once there is connection between the 2 switches a communication flow message is entered in the event log that the packets are sent between the switches. TCL STC OK 46378 NULL ALL BASELINE target:system:family:2510-24,target:system:family:2510-48,target:system:family:2510G,target:system:family:2520,target:system:family:2520G,target:system:family:2530ya,target:system:family:2530ya3,target:system:family:2530yb,target:system:family:2610,target:system:family:2615,target:system:family:2620,target:system:family:2626,target:system:family:2650,target:system:family:2810,target:system:family:2824,target:system:family:2848,target:system:family:2900,target:system:family:2910,target:system:family:2915,target:system:family:2920,target:system:family:3400,target:system:family:3500,target:system:family:3500jr,target:system:family:3500strk,target:system:family:3800,target:system:family:3800FIPS,target:system:family:4100,target:system:family:4200,target:system:family:5300,target:system:family:5400,target:system:family:5400FIPS,target:system:family:5400R,target:system:family:5400RFIPS,target:system:family:6100,target:system:family:6400,target:system:family:6600,target:system:family:8200,target:system:family:8200FIPS,target:system:family:Mako,target:system:family:stack-AR,target:system:family:stack-TA DebugLogging_F_08._IPv6_DHCPv6_Client 130309 WIRED scripts/testSuite/hostAgentFeatures/debugLogging/DebugLoggingDebugTypes/ipv6Dhcpv6Client.tcl This test case will verify if DUT sends dhcpv6-client logs to debug destination session. TCL STC OK 46372 NULL ALL BASELINE PSR target:system:family:2520,target:system:family:2520G,target:system:family:2530ya,target:system:family:2530ya3,target:system:family:2530yb,target:system:family:2615,target:system:family:2620,target:system:family:2824,target:system:family:2848,target:system:family:2900,target:system:family:2910,target:system:family:2915,target:system:family:2920,target:system:family:3500,target:system:family:3500jr,target:system:family:3500strk,target:system:family:3800,target:system:family:3800FIPS,target:system:family:4100,target:system:family:5400,target:system:family:5400FIPS,target:system:family:5400R,target:system:family:5400RFIPS,target:system:family:6100,target:system:family:6600,target:system:family:8200,target:system:family:8200FIPS,target:system:family:stack-AR,target:system:family:stack-TA DebugLogging_F_09._IPv6_Neighbor_Discovery 1069183 WIRED scripts/testSuite/hostAgentFeatures/debugLogging/debugLoggingFeatureTesting/DebugLoggingIPv6NeighborDiscovery.tcl

    but instead of this whole thing all i want is the string ending with .tcl ( like - DebugLoggingIPv6NeighborDiscovery.tcl)
    I ams tuck with how to parse this output.

    Guys pls help me..!!

  2. #2
    Join Date
    Mar 2014
    Posts
    6
    Someone pls help !!
    I am stuck here and cannot proceed !!

  3. #3
    Join Date
    Mar 2014
    Posts
    40
    Do you check W3C tutorial ? http://www.w3schools.com/XPath/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles