XPath.
-
One of those eureka moments occurred to me today. I needed to trawl through a rather heavily recursive xml file. While there weren't too many element names involved, they were sufficiently recursive enough to make it really horrible to debug in a recursive method. For sure, it worked but it didn't sit comfortably with me. It was then I recalled some XPath code I prototyped a couple of years ago. I opened the project and it occurred to me that XPath could actually simplify things for me. A couple of hours later I replaced my code with far easier to read path-like syntax. It didn't eliminate the recursion but appending new element names using subscripts just really made more sense in this case and it was a breeze to identify exactly where I was in the file. I'm not advocating XPath over any other strategy to process xml files but to this humble developer, it delivered far more maintainable code. Now that I think of it, there's another method in our app which processes some of the worst xml files I've ever come across. We're talking about 300 types of element some of them with many attributes as well. XPath might just simplify that as well. To the folks who put the XPath concept together, I thank you.:thumbsup:
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
-
One of those eureka moments occurred to me today. I needed to trawl through a rather heavily recursive xml file. While there weren't too many element names involved, they were sufficiently recursive enough to make it really horrible to debug in a recursive method. For sure, it worked but it didn't sit comfortably with me. It was then I recalled some XPath code I prototyped a couple of years ago. I opened the project and it occurred to me that XPath could actually simplify things for me. A couple of hours later I replaced my code with far easier to read path-like syntax. It didn't eliminate the recursion but appending new element names using subscripts just really made more sense in this case and it was a breeze to identify exactly where I was in the file. I'm not advocating XPath over any other strategy to process xml files but to this humble developer, it delivered far more maintainable code. Now that I think of it, there's another method in our app which processes some of the worst xml files I've ever come across. We're talking about 300 types of element some of them with many attributes as well. XPath might just simplify that as well. To the folks who put the XPath concept together, I thank you.:thumbsup:
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
Well, congratulations, and I look forward to reading your article on XPath here on CP ! cheers, Bill
“But I don't want to go among mad people,” Alice remarked. “Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.” “How do you know I'm mad?” said Alice. “You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll
-
Well, congratulations, and I look forward to reading your article on XPath here on CP ! cheers, Bill
“But I don't want to go among mad people,” Alice remarked. “Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.” “How do you know I'm mad?” said Alice. “You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll
I'm not so sure about that Bill but thanks for the endorsement. I might put something together as a snippet for the xml-related forum. I tell you, buddy, XPath really works rather well.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
-
One of those eureka moments occurred to me today. I needed to trawl through a rather heavily recursive xml file. While there weren't too many element names involved, they were sufficiently recursive enough to make it really horrible to debug in a recursive method. For sure, it worked but it didn't sit comfortably with me. It was then I recalled some XPath code I prototyped a couple of years ago. I opened the project and it occurred to me that XPath could actually simplify things for me. A couple of hours later I replaced my code with far easier to read path-like syntax. It didn't eliminate the recursion but appending new element names using subscripts just really made more sense in this case and it was a breeze to identify exactly where I was in the file. I'm not advocating XPath over any other strategy to process xml files but to this humble developer, it delivered far more maintainable code. Now that I think of it, there's another method in our app which processes some of the worst xml files I've ever come across. We're talking about 300 types of element some of them with many attributes as well. XPath might just simplify that as well. To the folks who put the XPath concept together, I thank you.:thumbsup:
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
I look forward to reading your article on XPath, and recursive XML files, here on CP !
“But I don't want to go among mad people,” Alice remarked. “Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.” “How do you know I'm mad?” said Alice. “You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll
-
One of those eureka moments occurred to me today. I needed to trawl through a rather heavily recursive xml file. While there weren't too many element names involved, they were sufficiently recursive enough to make it really horrible to debug in a recursive method. For sure, it worked but it didn't sit comfortably with me. It was then I recalled some XPath code I prototyped a couple of years ago. I opened the project and it occurred to me that XPath could actually simplify things for me. A couple of hours later I replaced my code with far easier to read path-like syntax. It didn't eliminate the recursion but appending new element names using subscripts just really made more sense in this case and it was a breeze to identify exactly where I was in the file. I'm not advocating XPath over any other strategy to process xml files but to this humble developer, it delivered far more maintainable code. Now that I think of it, there's another method in our app which processes some of the worst xml files I've ever come across. We're talking about 300 types of element some of them with many attributes as well. XPath might just simplify that as well. To the folks who put the XPath concept together, I thank you.:thumbsup:
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
Sorry but
XPath
is just horrible. The best way is to do aFile.ReadAllText
and then do all sorts toString
operations."Bastards encourage idiots to use Oracle Forms, Web Forms, Access and a number of other dinky web publishing tolls.", Mycroft Holmes[^]
-
One of those eureka moments occurred to me today. I needed to trawl through a rather heavily recursive xml file. While there weren't too many element names involved, they were sufficiently recursive enough to make it really horrible to debug in a recursive method. For sure, it worked but it didn't sit comfortably with me. It was then I recalled some XPath code I prototyped a couple of years ago. I opened the project and it occurred to me that XPath could actually simplify things for me. A couple of hours later I replaced my code with far easier to read path-like syntax. It didn't eliminate the recursion but appending new element names using subscripts just really made more sense in this case and it was a breeze to identify exactly where I was in the file. I'm not advocating XPath over any other strategy to process xml files but to this humble developer, it delivered far more maintainable code. Now that I think of it, there's another method in our app which processes some of the worst xml files I've ever come across. We're talking about 300 types of element some of them with many attributes as well. XPath might just simplify that as well. To the folks who put the XPath concept together, I thank you.:thumbsup:
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
It's short for psychopath, isn't it?
I wanna be a eunuchs developer! Pass me a bread knife!
-
It's short for psychopath, isn't it?
I wanna be a eunuchs developer! Pass me a bread knife!
It could well be.:thumbsup:
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.