Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

format xml data

New Here ,
Mar 20, 2008 Mar 20, 2008

Copy link to clipboard

Copied

Grasping for straws here, a newbi to spry and xml. I am trying to display numbers from an xml file. I have a number ei. 25450 which I need to display as $25,450.00.

Question #1 Do I format this in the xpath statement? Or do I add a xsl file?? Below, please find a sample form the xml file. <Price> is the element I need to format. As

Question #2 how do I get just the first jpg from the <Image> node, (order = “1”). Is this a separate dataset?

My xpath is var dstoys = new Spry.Data.XMLDataSet("../images/rvusa/database_export.xml", "Inventory/Dealer/Location/Units/Unit[Type ='Toy Hauler']");


<Inventory>
<Dealer>
<ID>422</ID>
<Name><![CDATA[client]]></Name>
<Location>
<ID>458</ID>
<Address>11572 Road</Address>
<City>Any Town</City>
<State>WA</State>
<ZipCode>98000</ZipCode>
<Phone>123-123-1234</Phone>
<Units>
<Unit>
<ID>482252</ID>
<Type><![CDATA[Park Model]]></Type>
<Condition><![CDATA[New]]></Condition>
<Stock_Number><![CDATA[1865]]></Stock_Number>
<Year><![CDATA[2008]]></Year>
<Manufacturer><![CDATA[Kropf]]></Manufacturer>
<Model><![CDATA[SESRLP]]></Model>
<Length>36</Length>
<MSRP>0</MSRP>
<Price>61545</Price>
<Sale_Price>0</Sale_Price>
<Description><![CDATA[Large bathroom with walk-in laundry room. Front living room, nice entertainment center. All residential appliances, 8" I-beam chassis with full outriggers, 2x4 sidewall framing 16" on-center. 50 year vinyl siding, fiberglass insulation R-22 in the roof, R-11 in the sidewalls and floor.]]></Description>
<Chassis><![CDATA[]]></Chassis>
<Engine_Manufacturer><![CDATA[]]></Engine_Manufacturer>
<Engine_Model><![CDATA[]]></Engine_Model>
<Fuel_Type><![CDATA[]]></Fuel_Type>
<Interior_Color><![CDATA[Rustic]]></Interior_Color>
<Exterior_Color><![CDATA[Tan]]></Exterior_Color>
<Sleep_Capacity />
<Water_Capacity />
<Num_Air_Conditioners>1</Num_Air_Conditioners>
<Mileage />
<Trailer_Weight />
<Num_Slideouts>0</Num_Slideouts>
<VIN><![CDATA[]]></VIN>
<Is_Special><![CDATA[False]]></Is_Special>
<Is_Sold><![CDATA[False]]></Is_Sold>
<Is_Consignment><![CDATA[False]]></Is_Consignment>
<Is_New_Arrival><![CDATA[False]]></Is_New_Arrival>
<Is_On_Deposit><![CDATA[False]]></Is_On_Deposit>
<Is_On_order><![CDATA[False]]></Is_On_order>
<Images>
<Image order="1"><![CDATA[ http://mydomain.com/images/482252_1.jpg
<Image order="2"><![CDATA[ http://mydomain.com/images/482252_2.jpg
<Image order="3"><![CDATA[ http://mydomain.com/images/482252_3.jpg
<Image
TOPICS
Extensions

Views

235
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 30, 2008 Mar 30, 2008

Copy link to clipboard

Copied

LATEST
This may be out of your control, and I'm no expert myself, but I think this xml sample isn't very well-formed. If you've created a javascript xml object, then you should be able to reference the specific child node by calling it by name. Check the Dreamweaver documentation for the appropriate call. Look for the Dreamweaver DOM. That might help some.

XML is very unforgiving, so if any of it's structure isn't right, you may not get an error message to tell you what went wrong. I ended up parsing my xml file using javascript string object's functions to extract the nodes I needed. Evenutally, I ended up creating my own xml editor extension.

Getting back to your xml, use only lowercase. Personally, I would use more attributes for parent nodes then nest the other nodes and close them off sooner. Then enter the price as an attribute of the stock item. When the price is extracted from the file to display to the user, format the display field as the propper currency type. You might also want to add the "currency" attribute to tell your formatter how to convert and display the price.

<inventory>
<item id="482252" stocknumber="1865" price="25450.00" currency="us">
<dealer id="422" name="client" location="458">
<address city="Any Town" state="WA" zip="98000" />
</dealer>
<description><![CDATA[Text goes here]></description>
<engine>
<manufacturer></manufacturer>
<model></model>
<fueltype></fueltype>
<length></length>
</engine.
</item>
<item id="">
[another one]
</item>
</inventory>

Hope this helps.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines