To direct P4Web to return output in XML format to a browser:
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.
P4Web's XML output is formatted as follows:
Attribute | Description |
command | The p4 command for which output is returned |
server | The host and port of the server that executed the command |
user | Perforce username |
client | Client workspace name |
time | The date and time the XML output was generated (in local P4Web time) Format: Day, DD MMM YYYY HH:MM:SS TMZ |
<perforce
command="filelog"
server="perforcehost:2000"
user="mrp4"
client="mrp4_win-mrp4"
time="Wed, 11 Jun 2008 10:30:17 PDT">
Example: <specdef>Client;code:301;rq;ro;seq:1;len:32;;Update;code:302;...;;LineEnd;code:310;type:select;fmt:L;len:12;val:local/unix/mac/win/share;;View;code:311;type:wlist;words:2;len:64;;</specdef>
Example:
<filelog>
[remaining output]
</filelog>
Example:
<revs> <rev value="2" id1="0"> ... </rev> <rev value="1" id1="1"> ... </rev> </revs>
Example:
<rev
value="20"
id1="44">
<change>5592</change>
<action>edit</action>
<type>text</type>
</rev>
Example:
<rev value="21" id1="43"> <change>5615</change> ... <desc>Add some examples with spaces in their names</desc> <hows> <how value="branch into" id1="43" id2="0"> <file>//depot/testing/job011981/Case/BranchView.cpp</file> <srev>#none</srev> <erev>#1</erev> </how> <how value="branch into" id1="43" id2="1"> <file>//depot/testing/job011981/Case/dir/BranchView.cpp</file> <srev>#none</srev> <erev>#1</erev> </how> </hows> </rev>
<error>Error text...</error>
<data>Data message...</data>
<info>Informational message...</info>
Example: <![CDATA[name: Mike email: [email protected]]]>