Re: parse string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Simple XML *should* give you all the info somewhere in its data
structures.

If not, there are at least 2 or 3 other XML parsers that have been
built s extensions to PHP over the years.

Plus there is at least one XML parser in PEAR, and probably one or
more in PECL.

A quick search on http://php.net will find them.

If all else fails, and you're really really stuck with no XML parsers
due to brain-dead web-hosting, it should take you about an hour to
hack a script to use http://php.net/explode and/or
http://php.net/preg_match_all to get the info you want, *IF* the XML
is predictable.

It is NOT recommended that you do this, but here is a start if you
really have no way to get a real XML parser on-board:

$string = '[insert your XML here]';
preg_match_all('/<(a-z)+\\s*(([a-z]+)="([^"]*)"\\s*)*\\s*\\/>/isU',
$string, $matches);
var_dump($matches);

You may want to find and download "The Regex Coach" program to help
you learn/understand Regular Expressions.

On Wed, January 18, 2006 12:12 pm, Ron Eggler (Paykiosks) wrote:
> Hi,
>
> I need to parse a String like pasted below for all information
> (values)
> those are included like 'var=value'. How can I do that? Are there any
> XML-parsing functions available those'd fit for that job? I've ust
> found
> that one (http://ca.php.net/simplexml) but it seems like i could use
> it
> only for exctracting the 'terms' cause they're in the format that
> simplexml
> expects.
> Thank you for every help!
>
> [String]
> <xs:response xmlns:xs="urn:pinXpressSchema">
> <SKUlisting>
> <globalInfo slogan="Welcome to PayGo!" supportPhone="1-866-339-3299"/>
> <carrierInfo carrier="Reconex (test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
> />
> <carrierInfo carrier="IDT POSA"
> icon="https://www.pinsprepaid.com/image.aspx?name="; />
> <carrierInfo carrier="IDT MasterCard"
> icon="https://www.pinsprepaid.com/image.aspx?name="; />
> <carrierInfo carrier="PLAYPHONE (Test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=PlayPhone-200x100.gif";
> />
> <carrierInfo carrier="EWI POSA TEST"
> icon="https://www.pinsprepaid.com/image.aspx?name=PayGo_200_100.gif";
> />
> <carrierInfo carrier="IDT POSA"
> icon="https://www.pinsprepaid.com/image.aspx?name="; />
> <carrierInfo carrier="IDT Visa"
> icon="https://www.pinsprepaid.com/image.aspx?name="; />
> <carrierInfo carrier="Bell Mobility (TEST)"
> icon="https://www.pinsprepaid.com/image.aspx?name="; />
> <carrierInfo carrier="Boost Mobile (Test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=c59-BoostMobile.gif";
> />
> <carrierInfo carrier="Cingular (test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=cing-blue.gif"; />
> <carrierInfo carrier="Page Plus (Test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=pageplus.gif"; />
> <carrierInfo carrier="T-Mobile (test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=c29-t-mobile_ticketlogo.gif";
> />
> <carrierInfo carrier="Unefon"
> icon="https://www.pinsprepaid.com/image.aspx?name=unefon_logo.gif"; />
> <carrierInfo carrier="Verizon (test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=verizon.gif"; />
> <carrierInfo carrier="Virgin Mobile (test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=Virgin+Mobile
> +200x100.gif" />
> <cardSKU category="Local Dial Tone/Telephone Service"
> distributor="EWI"
> discontinued="false" cardtype="PIN" transactionType="PURC">
>   <card cardID="180" carrier="Reconex (test)" partNumber="PN-180"
> region="Optional Services (test)" amount="5" wholesalePrice="4.5"
> icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
> upc="870368000420">
>     <cinfo costPerMinute="" lifetime="0" longDistRate=""
> roamingRate=""
> numberOfMin=""/>
>   </card>
>   <terms>
>     Refer to the Reconex brochure for complete terms and conditions.
>   </terms>
>   <pinfo type="Optional Services" value="Call Forwarding, Call
> Waiting,
> Caller ID, Three Way Calling, Speed Dialing &amp; Non-Published
> Number"/>
> </cardSKU>
> <cardSKU category="Local Dial Tone/Telephone Service"
> distributor="EWI"
> discontinued="false" cardtype="PIN" transactionType="PURC">
>   <card cardID="181" carrier="Reconex (test)" partNumber="PN-181"
> region="Optional Services (test)" amount="10" wholesalePrice="9"
> icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
> upc="870368000437">
>     <cinfo costPerMinute="" lifetime="0" longDistRate=""
> roamingRate=""
> numberOfMin=""/>
>   </card>
>   <terms>
>     Refer to the Reconex brochure for complete terms and conditions.
> </terms>
>   <pinfo type="Optional Services" value="Call Forwarding, Call
> Waiting,
> Caller ID, Three Way Calling, Speed Dialing &amp; Non-Published
> Number"/>
> </cardSKU>
> <cardSKU category="Local Dial Tone/Telephone Service"
> distributor="EWI"
> discontinued="false" cardtype="PIN" transactionType="PURC">
>   <card cardID="178" carrier="Reconex (test)" partNumber="PN-178"
> region="Regional Refill (test)" amount="52.99" wholesalePrice="47.7"
> icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
> upc="870368000413">
>     <cinfo costPerMinute="" lifetime="0" longDistRate=""
> roamingRate=""
> numberOfMin=""/>
>   </card>
>   <terms>
>     Refer to the Reconex brochure for complete terms and conditions.
>   </terms>
>   <pinfo type="Basic Service" value="Includes 30 days of basic service
> in
> select states.  Also includes variable state, federal &amp; service
> line
> fees"/>
> </cardSKU>
> <cardSKU category="Local Dial Tone/Telephone Service"
> distributor="EWI"
> discontinued="false" cardtype="PIN" transactionType="PURC">
>   <card cardID="177" carrier="Reconex (test)" partNumber="PN-177"
> region="Regional Starter (test)" amount="39" wholesalePrice="35.1"
> icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
> upc="870368000406">
>     <cinfo costPerMinute="" lifetime="0" longDistRate=""
> roamingRate=""
> numberOfMin=""/>
>   </card>
>   <terms>
>     Refer to the Reconex brochure for complete terms and conditions.
>   </terms>
>   <pinfo type="Basic Service" value="15 Days of basic service"/>
> </cardSKU>
> [/String]
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux