generating a unique value and adding it to a group of elements
-
Hello, I am trying to generate a unique value for a set of elements and place an element in each of the elements. They must have the same id but only the elements enclosed in an element like . So my XML Document looks like:
22 Test INC testdb Savings and Checking Escrow 2016-21-03 2016-21-15 23:52:33 EDT Maturity Notice Production 1345 345
5432
Primary owner
Lynn
Tanner
5677
Business phone
(111)111-11112456 Personal email kkkkkkkkk@eirco423.net 1135 Home phone (111)111-1111 5805 Joint owner Ultra Tanner 2456 4070 Residence 43 Times Ping Two Rail Lane Thomas Co Commons Oreland 1587 Force pay 4358 0000000000 E-statement only tay3456fgee@eircom.net
-
Hello, I am trying to generate a unique value for a set of elements and place an element in each of the elements. They must have the same id but only the elements enclosed in an element like . So my XML Document looks like:
22 Test INC testdb Savings and Checking Escrow 2016-21-03 2016-21-15 23:52:33 EDT Maturity Notice Production 1345 345
5432
Primary owner
Lynn
Tanner
5677
Business phone
(111)111-11112456 Personal email kkkkkkkkk@eirco423.net 1135 Home phone (111)111-1111 5805 Joint owner Ultra Tanner 2456 4070 Residence 43 Times Ping Two Rail Lane Thomas Co Commons Oreland 1587 Force pay 4358 0000000000 E-statement only tay3456fgee@eircom.net
Some thoughts as not sure what you are working with: Just use the ID of the parent element and don't bother to assign children ID's. If you are doing a LINQ query and target the parent element with the ID you are looking for your "result" will be the element along with its children which will have the "same ID" whether it is physically assigned or not. I also would guess that you are somehow programmatically creating the XML, adding to it occasionally or subtracting to update it. So, when you create a new element to add to your XML, include all children ID attributes at the time of creation. Hope that helps.
<sig notetoself="think of a better signature"> <first>Jim</first> <last>Meadors</last> </sig>
-
Some thoughts as not sure what you are working with: Just use the ID of the parent element and don't bother to assign children ID's. If you are doing a LINQ query and target the parent element with the ID you are looking for your "result" will be the element along with its children which will have the "same ID" whether it is physically assigned or not. I also would guess that you are somehow programmatically creating the XML, adding to it occasionally or subtracting to update it. So, when you create a new element to add to your XML, include all children ID attributes at the time of creation. Hope that helps.
<sig notetoself="think of a better signature"> <first>Jim</first> <last>Meadors</last> </sig>
What I want to do is import this into Access and query the tables. The problem is Access is picky about it and makes a table for everything so I need to be able to match the records. I have no control over creating the xml document but it is generated by a system.
-
What I want to do is import this into Access and query the tables. The problem is Access is picky about it and makes a table for everything so I need to be able to match the records. I have no control over creating the xml document but it is generated by a system.
OK, I'm guessing from that - you are not a developer? 2 ideas: Try importing into Excel. I've been able to work with XML files successfully there. Then you should be able to tweak it there. Easiest way would be to install Visual Studio latest free version and write a short query. P.S. The following code will do pretty much what you are saying in a Visual Basic Console Application:
Dim myXMLFileLocation As String = "" 'INSERT YOUR FILE LOCATION
Dim myXmlFile As XElement = XElement.Load(myXMLFileLocation)For Each ele In myXmlFile.Elements For Each child In ele.Descendants child.SetAttributeValue("type", ele.@type) Next Next Console.WriteLine(myXmlFile.ToString) Console.ReadLine() myXmlFile.Save(myXMLFileLocation)
<sig notetoself="think of a better signature"> <first>Jim</first> <last>Meadors</last> </sig>
-
OK, I'm guessing from that - you are not a developer? 2 ideas: Try importing into Excel. I've been able to work with XML files successfully there. Then you should be able to tweak it there. Easiest way would be to install Visual Studio latest free version and write a short query. P.S. The following code will do pretty much what you are saying in a Visual Basic Console Application:
Dim myXMLFileLocation As String = "" 'INSERT YOUR FILE LOCATION
Dim myXmlFile As XElement = XElement.Load(myXMLFileLocation)For Each ele In myXmlFile.Elements For Each child In ele.Descendants child.SetAttributeValue("type", ele.@type) Next Next Console.WriteLine(myXmlFile.ToString) Console.ReadLine() myXmlFile.Save(myXMLFileLocation)
<sig notetoself="think of a better signature"> <first>Jim</first> <last>Meadors</last> </sig>
Thank you Jim for your help but I think I solved the problem. I am a programmer and believe me I would have had this done in C# or VB sprinkle in some LINQ in less than an hour if I had my way. Loading it into Excel does work and is a valid solution, I just wanted to try to solve it with XSLT. I also need to automate this for everyday mail merges so Access is a nice easy solution for the company I work for. So below is my code:
/>
/>
-
Thank you Jim for your help but I think I solved the problem. I am a programmer and believe me I would have had this done in C# or VB sprinkle in some LINQ in less than an hour if I had my way. Loading it into Excel does work and is a valid solution, I just wanted to try to solve it with XSLT. I also need to automate this for everyday mail merges so Access is a nice easy solution for the company I work for. So below is my code:
/>
/>
:thumbsup: Good on solving it. I didn't realize you were trying to solve it with XSLT :sigh: I didn't look as I thought it would be a "display" stylesheet...
<sig notetoself="think of a better signature"> <first>Jim</first> <last>Meadors</last> </sig>