#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Location
    Toronto
    Posts
    4
    Rep Power
    0

    Unhappy Help me for formate XML


    This is my code
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
     
    <priceResponse> <customerNo>3465346346</customerNo>
     
    <userName>sales@insid.com</userName>
    <PriceAvailabilityList>
    <SKU>4638028</SKU>
     <mfgPN>BT457AA#ABC</mfgPN>
     <mfgCode>16996</mfgCode>
    <status>Active</status> 
    <description>PAVILION P6627C-B PC BUNDLE</description>
    <GlobalProductStatusCode>Active</GlobalProductStatusCode>
    <price>684.71</price>
    <totalQuantity>456</totalQuantity>
    <AvailabilityByWarehouse>
    <warehouseInfo>
    <number>26</number> <zipcode>B3S 1B3</zipcode> <city>Halifax, NS</city> <addr>Chain Lake Drive</addr></warehouseInfo> 
    <qty>0</qty>
    </AvailabilityByWarehouse>
    <AvailabilityByWarehouse>
    <warehouseInfo>
    <number>29</number> <zipcode>N1H 1B4</zipcode> <city>Guelph, ON</city> <addr>Woodlawn Road West</addr></warehouseInfo>
     <qty>0</qty></AvailabilityByWarehouse>
     <AvailabilityByWarehouse>
     <warehouseInfo>
    <number>31</number>  <zipcode>T2C 4G6</zipcode> <city>Calgary, AB</city> <addr>AVE SE</addr></warehouseInfo>
     <qty>0</qty>
    </AvailabilityByWarehouse>
    <AvailabilityByWarehouse>
     <warehouseInfo>
     <number>32</number> <zipcode>V7C 4N3</zipcode> <city>Richmond, BC</city> <addr>Hollybridge Way</addr>
    </warehouseInfo> 
    <qty>456</qty>
    </AvailabilityByWarehouse>
    <AvailabilityByWarehouse>
     <warehouseInfo>
    <number>98</number>
    <zipcode>00000</zipcode>
     <city>MFG Drop Shipped</city>
    <addr>MFG Drop Shipped</addr></warehouseInfo>
    <qty>0</qty></AvailabilityByWarehouse>
    <lineNumber>1</lineNumber>
    </PriceAvailabilityList>
    </priceResponse>
    I need php or xsl so I can show only the
    City Qty in a table format and at the end totalQuantity

    Can anybody help me please to show this as required?
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    Show you? No. We'll help you but we won't give you the solution. You're supposed to learn.

    Which would you prefer: PHP or XSLT?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Location
    Toronto
    Posts
    4
    Rep Power
    0
    Originally Posted by requinix
    Show you? No. We'll help you but we won't give you the solution. You're supposed to learn.

    Which would you prefer: PHP or XSLT?
    Yes I know, I tried with formatting with CSS but no luck.
    PHP Code:
    <AvailabilityByWarehouse>
     <
    warehouseInfo>
       <
    number>26</number
       <
    zipcode>B3S 1B3</zipcode
       <
    city>HalifaxNS</city>  
       <
    addr>Chain Lake Drive</addr>
      </
    warehouseInfo
     <
    qty>0</qty>
    </
    AvailabilityByWarehouse>

    <
    AvailabilityByWarehouse>
    <
    warehouseInfo>
    <
    number>29</number
    <
    zipcode>N1H 1B4</zipcode
    <
    city>GuelphON</city
    <
    addr>Woodlawn Road West</addr>
    </
    warehouseInfo>
     <
    qty>0</qty>
    </
    AvailabilityByWarehouse
    I seen example but there are one more deep
    like
    AvailabilityByWarehouse has two node warehouseInfo and qty

    and warehouseInfo have inside 4 nodes.
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Location
    Toronto
    Posts
    4
    Rep Power
    0

    Red face


    Originally Posted by requinix
    So which would you prefer: PHP or XSLT?
    PHP
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Location
    Toronto
    Posts
    4
    Rep Power
    0
    PHP Code:
    <div style="border-width: 3px; border-color: #457e92; border-style: ridge; width: 99%;">

    <table width="100%" border="0" bordercolor="#457D93">
      <tr>
        <td colspan="3" bordercolor="#457D93" class="headers style1" bgcolor="#FFFFFF"><font color=darkred>Real-time Stock Availability</font></td>
      </tr>

      <tr>
        <td width="35%" bordercolor="#666666" bgcolor="#F2F2F2" class="headers"><div align="center">Warehouse Location</div></td>
        <td width="25%" bordercolor="#666666" bgcolor="#F2F2F2" class="headers"><div align="center">Available</div></td>
      </tr>

    <?php

    if ($result<>'ERROR -> 404 Not Found'){

       
    $doc = new DOMDocument();
      
    $doc->loadXML$result );
      
    $AvailabilityByWarehouse $doc->getElementsByTagName"AvailabilityByWarehouse" );
     
     foreach( 
    $AvailabilityByWarehouse as $warehouseInfo )
            {

    $citys $warehouseInfo->getElementsByTagName"city" );
      
    $city $citys->item(0)->nodeValue;

          
      
    $qtys $warehouseInfo->getElementsByTagName"qty" );
      
    $qty $qtys->item(0)->nodeValue;
    ?>







          <tr>
            <td bordercolor="#666666" bgcolor="#F1F829" class="content"><?php echo $city?></td>

            <td bordercolor="#666666" bgcolor="#F1F829" class="content" align=center><font color=black><?php echo $qty?></font></td>
            </tr>
    <?php
      
      
    }
    }



    $totalQuantitys $doc->getElementsByTagName"totalQuantity" );
      
    $totalQuantity $totalQuantitys->item(0)->nodeValue;
    ?>

      <tr>

        <td bordercolor="#666666" bgcolor="#F2F2F2">&nbsp;</td>
        <td bordercolor="#666666" bgcolor="#F2F2F2" class="headers style1">Total Available: <font color=black><?php echo $totalQuantity ?></font></td>
      </tr>
    </TABLE>
    </div>
    Solved in quick and nasty way.
  12. #7
  13. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    That's not too bad actually. For DOM you did it pretty much the way it should be.

IMN logo majestic logo threadwatch logo seochat tools logo