We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

XML parsing with JSP, but not really JSP.

jhughes4
jhughes4 asked
on
Medium Priority
329 Views
Last Modified: 2013-11-24
Hello Experts.
I have a peculiar question.  I have a group of Siebel people who have to parse an XML message.  Siebel uses its own proprietary language for coding, but underneath its JSP.  The problem is that no one is familiar with JSP.  So with the limited knowledge of JSP and Siebel not able to parse using a utility like DOM, can someone provide some sample code that would parse this XML…PLEASE!  Thank you in advance.  If I could assign 1000 points to this I would.




<Transaction TargetApplicationName="String" DateTimeStamp="2001-12-17T09:30:47.0Z" TransactionIndicator="String">
      <Object2>
                <Contact searchspec="String" Transaction="Create">
                        <AgentNumber>111111</AgentNumber>
                  <ContactType>PY</ContactType>
                  <AgentType>FEO</AgentType>
                  <AgentTypeDescription>Part Time</AgentTypeDescription>
                  <AgentStatus>A</AgentStatus>
                  <AgentStatusDescription>Active</AgentStatusDescription>
                  <FillerField1>String</FillerField1>
                  <FillerField2>String</FillerField2>
                  <PersonalInformation>
                        <FirstName>Bob</FirstName>
                        <MiddleName>M</MiddleName>
                        <LastName>Smith</LastName>
                        <Suffix>Jr</Suffix>
                        <Designation>LUTUF;ABC</Designation>
                        <PreferredName>Willina</PreferredName>
                        <EmailAddress>sasdsad@abc.com</EmailAddress>
                  </PersonalInformation>
                  <ListOfAccount_BusinessAddress>
                        <AddressTypeCode>O</AddressTypeCode>
                        <AddressLine1>3041</AddressLine1>
                        <AddressLine2>Cochran</AddressLine2>
                        <City>some city </City>
                        <State>some state</State>
                        <Zip>10845</Zip>
                        <FillerField1>String</FillerField1>
                        <FillerField2>String</FillerField2>
                        <AddressTypeCode>M</AddressTypeCode>
                        <AddressLine1>3042</AddressLine1>
                        <AddressLine2>Cochran</AddressLine2>
                        <City>somecity</City>
                        <State>somestate</State>
                        <Zip>10845</Zip>
                        <FillerField1>String</FillerField1>
                        <FillerField2>String</FillerField2>
                  </ListOfAccount_BusinessAddress>
                  <RoleInformation>
                        <UniqueProducerNumber>11233433</UniqueProducerNumber>
                        <ProducerExpirationDate>03/21/2006</ProducerExpirationDate>
                        <LDAPId>String</LDAPId>
                        <CandidateCode>ABC</CandidateCode>
                        <AgencyName>AAAA Ins Company</AgencyName>
                        <SecondaryLegacyNumber>1111</SecondaryLegacyNumber>
                  </RoleInformation>
                  <OrganizationDetails>
                        <CodeType>DIV</CodeType>
                        <Code>01</Code>
                        <CodeDescription>Test Div 01</CodeDescription>
                        <CodeType>DIS</CodeType>
                        <Code>01</Code>
                        <CodeDescription>Test District 01</CodeDescription>
                        <CodeType>OFF</CodeType>
                        <Code>08</Code>
                        <CodeDescription>Test Office</CodeDescription>
                        <CodeType>ST</CodeType>
                        <Code>CA</Code>
                        <CodeDescription>adsfasdf</CodeDescription>
                        <CodeType></CodeType>
                        <Code></Code>
                        <CodeDescription></CodeDescription>
                  </OrganizationDetails>
                  <PhoneInformation>
                        <PhoneType>W</PhoneType>
                        <PhoneNumber>111111111</PhoneNumber>
                  </PhoneInformation>
                  <AwardInformation>
                        <AwardType>AG</AwardType>
                        <AwardDate>03/21/2006</AwardDate>
                        <AwardType>FA</AwardType>
                        <AwardDate>03/22/2006</AwardDate>
                        <AwardType>DE</AwardType>
                        <AwardDate>03/23/2006</AwardDate>
                        <AwardType></AwardType>
                        <AwardDate></AwardDate>
                  </AwardInformation>
            </Contact>
      </Object2>
</Transaction>

Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2006

Commented:
Sure. The only question is whether you want to parse this using some java code like DOM or SAX or whether you want to ouput this xml into a jsp.

As this is JSP I will guess the latter and say that you should use the JSTL libs  http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html
-----------------------------------------------
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<c:import var='xml' url='message.xml'/><!-- import your message file-->
<x:parse xml="${xml}" var="doc" />

<table>
      <tr>
                <!-- now use standard xpath to traverse the document -->
            <td><x:out select="$doc/Transaction/Object2/Contact/AgentNumber"/><!-- outputs "111111"--></td>
            <td><x:out select="$doc//FirstName"/><!-- outputs "Bob"--></td>
      </tr>
</table>
------------------------------------------------
If you need some java code to parse it then I can provide a utility class for that too.

Author

Commented:
I don't think that the JSTL is available to Siebel.  Is there another way?  Can you also provide the java code?  thanks
Commented:
you can find an example here...
http://www.experts-exchange.com/Web/Web_Languages/XML/Q_21773704.html

for more details on dom ...visit the below site...
http://www.dom4j.org/cookbook.html

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.