Hi i have folowinf XML. I don't need info from header i want to be able to extract and create HTML tabl;e for each field id="abonento-numeris" and populate with certain field values
lest say field abonento-numeris,abonentinis-mokestis(from eilutes-tipas "D"), kiti-mokesciai(from eilutes-tipas "S")
I tried nonverting it to JSON and then parse JSON but it does not return me my values.
How to work with such XML structure correctly?
<?xml version="1.0" encoding="UTF-8"?>
<documents>
<document id="konsoliduota-saskaita">
<header>
<parameter id="kliento-pavadinimas"> "Company"</parameter>
<parameter id="adresas1">Adress1</parameter>
<parameter id="adresas2">Adress2</parameter>
<parameter id="adresas3">Adress3</parameter>
<parameter id="adresas4" />
<parameter id="periodas">2022 09 01-2022 09 30</parameter>
<parameter id="kliento-numeris">393134</parameter>
<parameter id="dokumento-numeris">227651233</parameter>
<parameter id="dokumento-data">2022 09 30</parameter>
<parameter id="kredito-limitas">0000.00</parameter>
<parameter id="mokejimo-terminas">2022 10 31</parameter>
<parameter id="imones-kodas">11111111</parameter>
<parameter id="pvm-moketojo-kodas">111111114</parameter>
<parameter id="viso-uz-paslaugas-be-pvm">999.99</parameter>
<parameter id="viso-suma-be-pvm">666.66</parameter>
<parameter id="viso-suma-pvm">123.12</parameter>
<parameter id="viso-suma-su-pvm">1111.11</parameter>
</header>
<details>
<record>
<field id="abonento-tipas">GSM ryšio abonentai</field>
<field id="abonento-numeris">66666666</field>
<field id="abonento-vardas" />
<field id="mokejimo-planas">Verslas 0</field>
<field id="abonentinis-mokestis">0.00</field>
<field id="kiti-mokesciai">0.00</field>
<field id="vietiniai-balso-skambuciai">0.00</field>
<field id="vietiniai-sms">0.00</field>
<field id="vietinis-duomenu-perdavimas">0.00</field>
<field id="tarptautiniai-skambuciai">0.00</field>
<field id="tarptinkliniai-skambuciai">0.00</field>
<field id="kiti-papildomos-paslaugos">0.00</field>
<field id="nuolaida">0.00</field>
<field id="suma-be-pvm">0.00</field>
<field id="suma-pvm">0.00</field>
<field id="suma-su-pvm">0.00</field>
<field id="eilutes-tipas">D</field>
<field id="pvm-procentas">21</field>
</record>
<record>
<field id="abonento-tipas">GSM ryšio abonentai</field>
<field id="abonento-numeris">6666666</field>
<field id="abonento-vardas" />
<field id="mokejimo-planas">Verslas 0</field>
<field id="abonentinis-mokestis">0.00</field>
<field id="kiti-mokesciai">0.00</field>
<field id="vietiniai-balso-skambuciai">0.00</field>
<field id="vietiniai-sms">0.00</field>
<field id="vietinis-duomenu-perdavimas">0.00</field>
<field id="tarptautiniai-skambuciai">0.00</field>
<field id="tarptinkliniai-skambuciai">0.00</field>
<field id="kiti-papildomos-paslaugos">0.00</field>
<field id="nuolaida">0.00</field>
<field id="suma-be-pvm">0.00</field>
<field id="suma-pvm">0.00</field>
<field id="suma-su-pvm">0.00</field>
<field id="eilutes-tipas">S</field>
<field id="pvm-procentas" />
</record>
Your sample XML is missing the last three closing tags which would cause an error (not sure if you just missed them when pasting in here.
To convert to JSON you might need to convert to XML first. I've got a Compose that just holds the XML you provided, including the closing tags.
And then another Compose using the following expression:
json(xml(outputs('Compose')))
I then have a Parse JSON where I pass in the output of the Compose JSON, and I copy the Body of the Compose JSON after running it so I can then paste this into the Generate from sample to get my schema.
Full XML including closing tags:
<?xml version="1.0" encoding="UTF-8"?>
<documents>
<document id="konsoliduota-saskaita">
<header>
<parameter id="kliento-pavadinimas"> "Company"</parameter>
<parameter id="adresas1">Adress1</parameter>
<parameter id="adresas2">Adress2</parameter>
<parameter id="adresas3">Adress3</parameter>
<parameter id="adresas4" />
<parameter id="periodas">2022 09 01-2022 09 30</parameter>
<parameter id="kliento-numeris">393134</parameter>
<parameter id="dokumento-numeris">227651233</parameter>
<parameter id="dokumento-data">2022 09 30</parameter>
<parameter id="kredito-limitas">0000.00</parameter>
<parameter id="mokejimo-terminas">2022 10 31</parameter>
<parameter id="imones-kodas">11111111</parameter>
<parameter id="pvm-moketojo-kodas">111111114</parameter>
<parameter id="viso-uz-paslaugas-be-pvm">999.99</parameter>
<parameter id="viso-suma-be-pvm">666.66</parameter>
<parameter id="viso-suma-pvm">123.12</parameter>
<parameter id="viso-suma-su-pvm">1111.11</parameter>
</header>
<details>
<record>
<field id="abonento-tipas">GSM ryšio abonentai</field>
<field id="abonento-numeris">66666666</field>
<field id="abonento-vardas" />
<field id="mokejimo-planas">Verslas 0</field>
<field id="abonentinis-mokestis">0.00</field>
<field id="kiti-mokesciai">0.00</field>
<field id="vietiniai-balso-skambuciai">0.00</field>
<field id="vietiniai-sms">0.00</field>
<field id="vietinis-duomenu-perdavimas">0.00</field>
<field id="tarptautiniai-skambuciai">0.00</field>
<field id="tarptinkliniai-skambuciai">0.00</field>
<field id="kiti-papildomos-paslaugos">0.00</field>
<field id="nuolaida">0.00</field>
<field id="suma-be-pvm">0.00</field>
<field id="suma-pvm">0.00</field>
<field id="suma-su-pvm">0.00</field>
<field id="eilutes-tipas">D</field>
<field id="pvm-procentas">21</field>
</record>
<record>
<field id="abonento-tipas">GSM ryšio abonentai</field>
<field id="abonento-numeris">6666666</field>
<field id="abonento-vardas" />
<field id="mokejimo-planas">Verslas 0</field>
<field id="abonentinis-mokestis">0.00</field>
<field id="kiti-mokesciai">0.00</field>
<field id="vietiniai-balso-skambuciai">0.00</field>
<field id="vietiniai-sms">0.00</field>
<field id="vietinis-duomenu-perdavimas">0.00</field>
<field id="tarptautiniai-skambuciai">0.00</field>
<field id="tarptinkliniai-skambuciai">0.00</field>
<field id="kiti-papildomos-paslaugos">0.00</field>
<field id="nuolaida">0.00</field>
<field id="suma-be-pvm">0.00</field>
<field id="suma-pvm">0.00</field>
<field id="suma-su-pvm">0.00</field>
<field id="eilutes-tipas">S</field>
<field id="pvm-procentas" />
</record>
</details>
</document>
</documents>
@grantjenkins Yes i know it is missing i just pasted the small part from xml
I already have done as you have described look:
convert to XML
convert XML to JSON
Parse JSON
And then i try in compose to reach some element but this is what i get
I can not get to the fields values
Ah ok - sounds like a fun challenge (love working on this sort of stuff). I'm just off to bed now but will try to get what you're after tomorrow.
Did you just want the fields, or the parameters too?
I gues i need also a parameter cause i want to contrsct a html table where i imagine the html column name will be parameter and value will be the parameter text value
Just confirming - would this JSON be appropriate for your needs? It will allow for multiple documents, and within each document, multiple records, and for each record, multiple fields. Each document would have a unique id.
{
"documents": [
{
"id": "konsoliduota-saskaita",
"records": [
{
"abonento-tipas": "GSM ryšio abonentai",
"abonento-numeris": "66666666",
"pvm-procentas": "21"
},
{
"abonento-tipas": "XXXGSM ryšio abonentai",
"abonento-numeris": "XXX66666666",
"pvm-procentas": "XXX21"
}
]
},
{
"id": "konsoliduota-saskaitaV2",
"records": [
{
"abonento-tipas": "AAAGSM ryšio abonentai",
"abonento-numeris": "AAA66666666",
"pvm-procentas": "AAA21"
},
{
"abonento-tipas": "BBBGSM ryšio abonentai",
"abonento-numeris": "BBB66666666",
"pvm-procentas": "BBB21"
}
]
}
]
}
I think it would be ok. I also don't need the header i only need to access as you say access each record with it's multiple fields.
@jja thanks. Also are you able to send through what you would want for your HTML table output? In your original post you said you'd have a separate HTML table for each record.
I've got it working using xml and xpath and not converting to JSON.
It currently loops through each document, and within the document loops through each record, and builds an HTML table for each list of fields for the record. I'll have to finish it off tomorrow as off to sleep.
As an example - it looks like that below:
What did you want to do with the HTML tables? Were you going to add them to an email to be sent out for each record?
Ok - will work on that format. Assuming you would want a separate table per document since each document has multiple records.
And did you want it to have all the fields, or able to choose which ones you want in the table?
i would like to choose the fields to add to a table
And the outcome shouild be only one html table.
l
like from example the main record is abonento-numeris and this field should folow to it's right in the html table with it's data from field id="eilutes-tipas">D</field> and field id="eilutes-tipas">S</field> cause if you see abonento numeris has 2 types of eilutes-tipas. type D and type S when i have the data i will need to sum one particular field fronm eilutes-tipas S with a field from eilutes tipas D
What about if there's more than one document? Did you mean one HTML table per document?
As far as i have examined there is only one document which has document id=konsiliduota saskaita
that in this case is a document header which i will not take data from
With xpath i want to take this part
documents/document/details/record
for me the main identificator of the record is abonento-numeris and i want to be able to put into a table related data to each abonento numeris
Hopefully this is what you are after. I've used a Select to build up the dataset that you can then just pass into a Create HTML table or Create CSV table. Note that I added two documents to the XML since it had an element called Documents (just for testing purposes).
The full flow is below. I'll go into each of the actions.
The Compose contains your XML data.
The XML is another Compose which just wraps the above data into proper XML using the expression xml. Effectively, it's just telling Power Automate to treat it as proper XML. You may not need to do this if your data has already come through as XML.
xml(outputs('Compose'))
I then have an Apply to each to iterate over each document contained in the XML. The expression I use here is:
xpath(outputs('XML'), '//documents/document')
I then use a Select to build up the data structure for each record. The input uses the following expression:
xpath(items('Apply_to_each_document'), '//document/details/record')
For each of the mappings I've used the following expression. Note that it uses first as our xpath expression will always return an array and you only want the first item. If there are no items, it will return null.
first(xpath(item(), '//field[@id="YOUR_ID"]/text()'))
See a full listing of the mappings for each property below:
first(xpath(item(), '//field[@id="abonento-numeris"]/text()'))
first(xpath(item(), '//field[@id="abonento-tipas"]/text()'))
first(xpath(item(), '//field[@id="abonento-vardas"]/text()'))
first(xpath(item(), '//field[@id="mokejimo-planas"]/text()'))
first(xpath(item(), '//field[@id="abonentinis-mokestis"]/text()'))
first(xpath(item(), '//field[@id="kiti-mokesciai"]/text()'))
first(xpath(item(), '//field[@id="vietiniai-balso-skambuciai"]/text()'))
first(xpath(item(), '//field[@id="vietiniai-sms"]/text()'))
first(xpath(item(), '//field[@id="vietinis-duomenu-perdavimas"]/text()'))
first(xpath(item(), '//field[@id="tarptautiniai-skambuciai"]/text()'))
first(xpath(item(), '//field[@id="tarptinkliniai-skambuciai"]/text()'))
first(xpath(item(), '//field[@id="kiti-papildomos-paslaugos"]/text()'))
first(xpath(item(), '//field[@id="nuolaida"]/text()'))
first(xpath(item(), '//field[@id="suma-be-pvm"]/text()'))
first(xpath(item(), '//field[@id="suma-pvm"]/text()'))
first(xpath(item(), '//field[@id="suma-su-pvm"]/text()'))
first(xpath(item(), '//field[@id="eilutes-tipas"]/text()'))
first(xpath(item(), '//field[@id="pvm-procentas"]/text()'))
You can then use the output of the Select to create your HTML and CSV tables as so:
Let me know if any issues, questions.
How do i filter only records where eilutes-tipas="D" and return only them?
i try to build this xpath expresion but it doesn ot work
/documents/document/details/record/field[@id="eilutes-tipas"]/text()='D'
You would do something like that below to get the actual record.
//documents/document/details/record[field[@id='eilutes-tipas']/text()='D']
Or if you wanted to find something that starts with a certain character(s).
//documents/document/details/record[starts-with(field[@id='abonento-tipas']/text(),'GSM')]
Little by little i am aproaching to final result. can you help me now how to do this:
I have filtered the array by eilutes-tipas=D but in most cases i have 2 same aray records with same -abonento-numeris but different pvm-procentas
Now i want to perform some grouping and some math functions how to do that. For example:
{
"abonento-numeris": "66666666",
"abonento-vardas": "Firstname Lastname",
"suma-be-pvm": "17.52",
"kiti-papildomos-paslaugos": "3.40",
"eilutes-tipas": "D",
"pvm-procentas": "21"
},
{
"abonento-numeris": "666666667",
"abonento-vardas": "Firstname Lastname",
"suma-be-pvm": "15.70",
"kiti-papildomos-paslaugos": "3.80",
"eilutes-tipas": "D",
"pvm-procentas": "Ne obj."
},
What i need to do is to group by either abonento-numeris or abonento-vardas
then SUM(suma-be-pvm) from both records and then substract this amount by field value kiti-papildomos-paslaugos which in this case is 3.80. This amount comes from the record where pvm-procentas pvm-procentas": "Ne obj."
So my final html or csv table should look like this in different coluymns:
Abonento numeris or abonento vardas; (suma-be-pvm+suma-be-pvm)-kiti-papildomos-paslaugos(from pvm-procentas": "Ne obj." record) and the kiti-papildomos-paslaugos(from pvm-procentas": "Ne obj." record) amount it self
Do you have an idea how to achieve this?
Dear Community Members, We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd. During this period, members will not be able to Kudo, Comment, or Reply to any posts. On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities. What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!
We are excited to announce the Summer of Solutions Challenge! This challenge is kicking off on Monday, June 17th and will run for (4) weeks. The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities. Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”) - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024 Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods. You must enter into each weekly Entry Period separately. How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different. Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers. At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing. Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner. A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random. Individuals will be contacted before the announcement with the opportunity to claim or deny the prize. Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners. Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event. ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE** Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24 17 @Anil_g 7 @ManishSolanki 13 @eetuRobo 5 @David_MA 10 @VishnuReddy1997 5 @SpongYe 9JhonatanOB19932 (tie) @Nived_Nambiar 8 @maltie 2 (tie) @PA-Noob 2 (tie) @LukeMcG 2 (tie) @tgut03 2 (tie) Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate @Deenuji 12@ManishSolanki 19 @Anil_g 10 @NathanAlvares24 17 @VishnuReddy1997 6 @Expiscornovus 10 @Tjan 5 @Nived_Nambiar 10 @eetuRobo 3 @SudeepGhatakNZ 8 Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22 Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2 Anil_g2 SharonS2
On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners. The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights. Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.
We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for. We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer. Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together. Here's to new beginnings and endless possibilities! If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport. To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages