Requesting XML output from P4Web

P4Web normally returns results as HTML. However, you can direct P4Web to return results encoded as XML, as follows.

In a browser

To direct P4Web to return output in XML format to a browser:

  1. To display the P4 command field, click .
  2. In the P4 command field, type the desired command and click the XML radio button.
  3. Click Go. XML output for the specified command is displayed in the browser.

From a script

To request XML output from P4Web using a script, specify action code 201 in the URL that you submit. The following example shows how to request XML output in a Perl script using the standard LWP module to issue a web request. P4Web returns its XML output into the variable $page. The example request issues the p4 changes command to obtain detailed information about changelists, limiting the output to 50 changelists using the -m flag.

 use LWP::Simple; 
 my $url = 'http://myserver.perforce.com:8080/p4%20changes%20-m%2050%20-l?ac=201';  
 my $page = get $url; 
When developing scripts, use the browser to display the XML results, to help you determine the output that your script must parse.

Format of P4Web's XML Output

PWeb's XML output is formatted as follows:

  • Informational output is enclosed in identifying tags, in the following format:
    	<error>Error text...</error>
    	<data>Data message...</data>
    	<info>Informational message...</info>

  • Data that contains a line-feed, TAB or space-space is tagged as CDATA to preserve white space characters. CDATA is always uppercase.

    Example: <![CDATA[name: Mike email: tomb@mydata.selmatter@us.oracle.com]]>