School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,579 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,241 people online right now. Registration is fast and FREE... Join Now!




Parsing XML

 

Parsing XML

xheartonfire43x

1 Apr, 2009 - 11:15 AM
Post #1

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 260



Thanked: 2 times
My Contributions
Hey everyone,

I am working on integrating USPS into a shopping cart that I am building and am having problems converting the shipping rates that I recieve back into something useable.

This is the xml that I recieve.
CODE

<RateV3Response>
  <Package ID="1">
    <ZipOrigination>85085</ZipOrigination>
    <ZipDestination>32909</ZipDestination>
    <Pounds>4</Pounds>
    <Ounces>0</Ounces>
    <Size>REGULAR</Size>
    <Machinable>TRUE</Machinable>
    <Zone>8</Zone>
    <Postage CLASSID="4">
        <MailService>Parcel Post</MailService>
        <Rate>9.38</Rate>
    </Postage>
  </Package>
</RateV3Response>


I want the <rate> I don't care about anything else. I don't have any other code than that to help y'all help me. I am sure it is just a simple <cfset> with a function but I don't know XML functions at all.

User is offlineProfile CardPM
+Quote Post


sansclue

RE: Parsing XML

1 Apr, 2009 - 12:06 PM
Post #2

D.I.C Regular
***

Joined: 21 Nov, 2007
Posts: 316



Thanked: 28 times
My Contributions
QUOTE(xheartonfire43x @ 1 Apr, 2009 - 11:15 AM) *

I don't know XML functions at all.


Take a look at the documentation on XMLParse, especially usage. With well formed xml, it is just a matter of calling xmlParse. Then referencing the key you need. You may also need to consult the usps api, to understand how to reference the key.
http://livedocs.adobe.com/coldfusion/7/htm...0671.htm#139864

CODE

<cfset responseXML = xmlParse(yourString)>
<cfset rate = xmlRoot.pathToTheKeyYouWant.xmlText>




User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 08:24AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month