Results 1 to 4 of 4

Thread: create xml from existing xml file - somebody help me on this please

  1. #1

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    create xml from existing xml file - somebody help me on this please

    Hi all,

    I want to retrieve specific nodes and create a new xml from that.

    I have XML file as shown below:
    Code:
    <log>
    	<ID>1502</ID>
    	<Brand>green</Brand>
    	<Type>fruits</Type>
    	<FruitsInfo>
    		<ShopNo>1000</ShopNo>
    		<date>18-Apr-2005</date>
    		<time>16:14:22<time>
    		<Stock>
    			<item>Banana</item>
    			<item>Apple</item>
    			<item>Grapes</item>
    			<item>Mango</item>
    			<item>Others</item>
    		</Stock>
    	</FruitsInfo>
    	<FruitsInfo>
    		<ShopNo>1001</ShopNo>
    		<date>18-Apr-2005</date>
    		<time>16:14:22<time>
    		<Stock>
    			<item>Banana</item>
    			<item>Apple</item>
    			<item>Grapes</item>
    			<item>Mango</item>
    			<item>Others</item>
    		</Stock>
    	</FruitsInfo>
    </log>
    I need output xml for a given shop number. Let's say the user wants to know about shop no: 1000, then the output xml should be:
    Code:
    <log>
    	<ID>1502</ID>
    	<Brand>green</Brand>
    	<Type>fruits</Type>
    	<FruitsInfo>
    		<ShopNo>1000</ShopNo>
    		<date>18-Apr-2005</date>
    		<time>16:14:22<time>
    		<Stock>
    			<item>Banana</item>
    			<item>Apple</item>
    			<item>Grapes</item>
    			<item>Mango</item>
    			<item>Others</item>
    		</Stock>
    	</FruitsInfo>
    </log>
    i.e., I want to extract all nodes for given shop no and all the lines/nodes before "FruitsInfo" node.

    Thanks in advance.


    Kanna.
    Last edited by csKanna; May 4th, 2006 at 02:52 AM.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Re: Need Help to create a xml from existing xml file.

    You should be able to apply the techniques I've shown you in your other post to this problem.

    Regards,

    - Aaron.

  3. #3

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Re: Need Help to create a xml from existing xml file.

    Thanks!

    But what I want to do is:
    Code:
    '~~~~~~~~~~~~~~~Header Part Begin~~~~~~~~~~~~~~~
    <log>
    	<ID>1502</ID>
    	<Brand>green</Brand>
    	<Type>fruits</Type>
    '~~~~~~~~~~~~~~~ Header Part End ~~~~~~~~~~~~~~~
    	<FruitsInfo>
    		<ShopNo>1000</ShopNo>
    		<date>18-Apr-2005</date>
    		<time>16:14:22<time>
    		<Stock>
    			<item>Banana</item>
    			<item>Apple</item>
    			<item>Grapes</item>
    			<item>Mango</item>
    			<item>Others</item>
    		</Stock>
    	</FruitsInfo>
    	<FruitsInfo>
    		<ShopNo>1001</ShopNo>
    		<date>18-Apr-2005</date>
    		<time>16:14:22<time>
    		<Stock>
    			<item>Banana</item>
    			<item>Apple</item>
    			<item>Grapes</item>
    			<item>Mango</item>
    			<item>Others</item>
    		</Stock>
    	</FruitsInfo>
    </log>
    As I told in my previous post I want to create a new xml file with header part and with nodes for a given shop no. Please refer post #1 for example output file.

    The number of lines in header part may differ. Simply saying, the header part is from the very first line to the line till it finds the <FruitsInfo> node.

    Thanks in advance.

  4. #4

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Re: create xml from existing xml file - somebody help me on this please

    somebody help me on this please

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width