[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: R: Reading XML with &Amp; as part of string
Venter,
Replace your copy of Expat with the one from LIBHTTP. Then use this program to parse your XML:
H DFTACTGRP(*NO) BNDDIR('HTTPAPI')
FQSYSPRT O F 132 PRINTER OFLIND(*INOF)
/copy qrpglesrc,httpapi_h
/copy qrpglesrc,ifsio_h
D Incoming PR
D userdata * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 65535A varying const
D Attrs * dim(32767)
D const options(*varsize)
D num s 10I 0
D item ds occurs(10)
D title 512A varying
D artlink 512A varying
D msg s 50A
D rc s 10I 0
D url s 100A varying
D PrintLine s 132A
D x s 10I 0
D filename s 45A varying
/free
*inlr = *on;
http_debug(*ON);
// ****************************************************
filename = '/tmp/Venter.xml';
// ****************************************************
// parse the XML from the temp file.
// ****************************************************
if (http_parse_xml_stmf( filename
: HTTP_XML_CALC
: *null
: %paddr(Incoming)
: *null ) < 0 );
PrintLine = http_error();
endif;
return;
/end-free
OQSYSPRT E
O PrintLine 132
P Incoming B
D Incoming PI
D userdata * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 65535A varying const
D attrs * dim(32767)
D const options(*varsize)
D count s 10I 0
D attrname s 1024A varying
D attrval s 65535A varying
/free
PrintLine = 'P:' + path;
except;
PrintLine = ' N:' + name;
except;
PrintLine = ' V:' + value;
except;
if (name = 'p1:Process') or
(name = 'p1:workstation');
count = 1;
dow http_nextXmlAttr(attrs: count: attrname: attrval);
PrintLine = ' A:' + %trim(attrname) + '=' + attrval;
except;
enddo;
endif;
/end-free
P E
-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Venter.Derick@xxxxxxxxxxxxxx
Sent: Thursday, November 07, 2013 2:36 AM
To: HTTPAPI and FTPAPI Projects
Subject: Re: R: Reading XML with &Amp; as part of string
Hi Scott
No I am not using the HTTPAPI's XML parser. We installed the LIBEXPAT
library from your web site and I am using the USERDATA.rpgle as an example
for my program. (Sorry not the XPATH.rpgle as i mentioned in my previous
mail)
It seems like it is reading the text after the &. If i print the value
to the spoolfile it prints an & and then on the next line the rest of the
text.
eg:
&
Num2
Here's the code to read the value from the tag:
WHEN d.stack(d.depth) = '/soapenv:Envelope/soapenv:Body'
+'/p1:CorticonResponse/p1:WorkDocuments'
+'/p1:Process'
+'/p1:routeProcessStep';
PrintMe = %TRIM(%char(val));
Except Print;
DoW %Scan(' & ': %TRIM(%char(val))) > *Zeros;
val = %Replace('&' : %TRIM(%char(val))
: %Scan(' & ': %TRIM(%char(val))): 7);
EndDo;
PrintMe = %TRIM(%char(val));
Except Print;
%OCCUR(PROCESSDATA) = d.procCnt;
PROCESSDATA.RTEPROCSTEP = %TRIM(%char(val));
Here's my xml:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<p1:CorticonResponse ccExeStart="1383656944646"
ccExeStop="1383656944677" decisionServiceName="cascading"
xmlns:p1="urn:Corticon">
<p1:WorkDocuments xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
">
<p1:Process id="HBCB20130822002338316B20130822002338318"
newOrModified="true">
<p1:lengthYieldFactor>0</p1:lengthYieldFactor>
<p1:lineOperationMode>RECL</p1:lineOperationMode>
<p1:overwindEntryCode>O</p1:overwindEntryCode>
<p1:overwindExitCode>O</p1:overwindExitCode>
<p1:pcpIndicator>true</p1:pcpIndicator>
<p1:processCode>HBC</p1:processCode>
<p1:routeProcessStep>Num1 & Num2</p1:routeProcessStep>
<p1:trimmingYieldFactor>0</p1:trimmingYieldFactor>
<p1:inProduct href="#B20130628002168289"/>
<p1:outProduct href="#Product_id_1"/>
<p1:workstation
href="HBCAP1B20130822002338316B20130822002338318"/>
</p1:Process>
</p1:WorkDocuments>
<p1:Messages version="1"/>
</p1:CorticonResponse>
</soapenv:Body>
</soapenv:Envelope>
Derick Venter
Applications Developer IV
Systems Integration
Tel: +27 (13) 247 2816 Fax: +27 (0) 86 573 2274
Cell: +27 (0) 83 458 6599
Email: derick.venter@xxxxxxxxxx
www.gijima.com
From: Scott Klement <sk@xxxxxxxxxxxxxxxx>
To: HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
Date: 2013/11/06 05:09 PM
Subject: Re: R: Reading XML with &Amp; as part of string
Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
So you are not using HTTPAPI's XML parser?!
On 11/6/2013 8:12 AM, Venter.Derick@xxxxxxxxxxxxxx wrote:
> The replacement of & with & works with plain RPG code using a
> string value.
> The problem is that the reader of the xml field seems to read &
> correct but the rest of the string is thrown away.
> When I print the value to the spool file, I see the following:
> &
> the rest of my string.
> Seems that the reader is adding a next line character.
> I used Scott Klement's XPATH example to read through my XML document
> and parse it.
> Any ideas?
> Derick Venter
> Applications Developer IV---
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
-------------------------------------------------------------------------------------
This e-mail is subject to the Columbus Stainless [Pty] Ltd Email Legal Notices available at: http://www.columbus.co.za/EmailLegalNotice.htm.
-------------------------------------------------------------------------------------
This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal
-------------------------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------