some additional bits of Knowledge about XPath will lead you forward towards your solution. Especially try to get information about how to figure out "parent nodes" of your target nodes.
One possible algorithm is to not iterate over the different orders(idpurchaseorder), but iterate over the different products(idproduct) and get the parent node(idpurchaseorder) from there.
Regards,
stomp.
P. S.: @Mod or @SDohmen: please fix the typo in the xml above: <name>Productname/name>
P. P. S.: I did not know the solution before the question was asked, and - according to Neos request - I will not take the fun and potential for growth from the poster to figuring it out for his-/herself. (The solution is about the same in size as the current shown attempts).
P. P. P. S: +1 Point for SDohmen using the right tool for the right task. ;-)
Thank you for the comment. I edited the text to have the xml correctly displayed.
I think i know what you mean by selecting the subnodes first but i have no clue how to get the rest filled in.
When i change the line to the one below:
i am getting the text as above except switched around so that was not what you mean i guess.
Do you have any more clues what to look for?
i did search around some more and found the link below:
This looks a bit like it but i am not sure if that is the correct direction.
Hi,
Can anyone tell the option to change the file type in unix.
i.e. if a file is in csv(Comma Separating Values) format, it should be changed to xls(ordinary MS-Excel) format. But renaming command is not changing to correct file format.
Thanks in advance,
Milton. (1 Reply)
I am trying to check each line and based on first two digits, the comma needs to be place. I checked in the earlier post where the text is converted to csv with a tab delimited.
Here is the test file that needs to be changed to csv
11 051701
22 051701
330123405170105170112345... (13 Replies)
I'm new to shell scripting and I have a file with positional columns. The rows look like this:
222 3333 44444 55 55 55 55 5555 59999
222 3333 44444 55 55 55 55 5555 59999
Not every row has the same number of spaces between the seven columns. They can range anywhere... (11 Replies)
Hello Friends,
I am new to UNIX shell scripting. Using bash....Could you please help me in converting a flat file into an XML style output file.
Flat file: (Input File entries looks like this)
John Miller: 617-569-7996:15 Bunting lane, staten Island, NY: 10/21/79: 60600
The... (4 Replies)
Hej All,
I have a file like this which is a comma dilimited:
input:
6000318,-263.011520678,-59.05869872409,587.67924868792
6000319,-265.6996842902,-50.24902479999,590.65693082607
6000320,-238.1333898366,-288.801232595,633.75332173496... (5 Replies)
Hi Friends,
I want to convert a XML file to flat file.
Sample I/p:
<?xml version='1.0' encoding='UTF-8' ?>
<DataFile xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' contactCount='4999' date='2012-04-14' time='22:00:14' xsi:noNamespaceSchemaLocation='gen
.xsd'>
<Contact... (3 Replies)
I have a table as following
Archive id Line Author Time Text
1fjj34 3 75jk5l 03:20 this is an evidence regarding ...
1fjj34 4 gjhhtrd 03:21 we have seen those documents before
1fjj34 10 645jmdvvb 04:00 Will you consider such an offer?... (0 Replies)
Hi,
I have a xml script, I converted it to .txt with values comma seperated using awk function. But I want the output values should be inside double quotes
My xml script (Workorders.xml) is shown like below:
<?xml version="1.0" encoding="utf-8" ?>
<scbm-extract version="3.3">... (8 Replies)
Discussion started by: Viswanatheee55
8 Replies
LEARN ABOUT DEBIAN
test::xml::simple
Test::XML::Simple(3pm) User Contributed Perl Documentation Test::XML::Simple(3pm)NAME
Test::XML::Simple - easy testing for XML
SYNOPSIS
use Test::XML::Simple tests=>5;
xml_valid $xml, "Is valid XML";
xml_node $xml, "/xpath/expression", "specified xpath node is present";
xml_is, $xml, '/xpath/expr', "expected value", "specified text present";
xml_like, $xml, '/xpath/expr', qr/expected/, "regex text present";
xml_is_deeply, $xml, '/xpath/expr', $xml2, "structure and contents match";
# Not yet implemented:
# xml_like_deeply would be nice too...
DESCRIPTION
"Test::XML::Simple" is a very basic class for testing XML. It uses the XPath syntax to locate nodes within the XML. You can also check all
or part of the structure vs. an XML fragment.
TEST ROUTINES
xml_valid $xml, 'test description'
Pass an XML file or fragment to this test; it succeeds if the XML (fragment) is valid.
xml_node $xml, $xpath, 'test description'
Checks the supplied XML to see if the node described by the supplied XPath expression is present. Test fails if it is not present.
xml_is_long $xml, $xpath, $value, 'test description'
Finds the node corresponding to the supplied XPath expression and compares it to the supplied value. Succeeds if the two values match.
Uses Test::More's "is" function to do the comparison.
xml_is $xml, $xpath, $value, 'test description'
Finds the node corresponding to the supplied XPath expression and compares it to the supplied value. Succeeds if the two values match.
Uses Test::LongString's "is_string" function to do the test.
xml_like_long $xml, $xpath, $regex, 'test description'
Find the XML corresponding to the the XPath expression and check it against the supplied regular expression. Succeeds if they match. Uses
Test::More's "like" function to do the comparison.
xml_like $xml, $xpath, $regex, 'test description'
Find the XML corresponding to the the XPath expression and check it against the supplied regular expression. Succeeds if they match. Uses
Test::LongString's "like_string" function to do the test.
xml_is_deeply_long $xml, $xpath, $xml2, 'test description'
Find the piece of XML corresponding to the XPath expression, and compare its structure and contents to the second XML (fragment) supplied.
Succeeds if they match in structure and content. Uses Test::More's "is" function to do the comparison.
xml_is_deeply $xml, $xpath, $xml2, 'test description'
Find the piece of XML corresponding to the XPath expression, and compare its structure and contents to the second XML (fragment) supplied.
Succeeds if they match in structure and content. Uses Test::LongString's "is_string" function to do the test.
AUTHOR
Joe McMahon, <mcmahon@cpan.org>
LICENSE
Copyright (c) 2005 by Yahoo! and Joe McMahon
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.1 or,
at your option, any later version of Perl 5 you may have available.
SEE ALSO
XML::XPath, Test::More, Test::Builder.
perl v5.14.2 2012-06-05 Test::XML::Simple(3pm)