Hi all
I have the following simplified XML
<Formats> <Bank id="1" name="AIB"> <Content text = "line1" value="value1"/> <Content text = "line2" value="value2"/> </Bank> <Bank id="2" name="Barclays"> <Content text = "line1" value="value1"/> <Content text = "line2" value="value2"/> <Content text = "line3" value="value3"/> </Bank> </Formats>
With the following code I can iterate through the banks and display their names as follows
goXML = CREATEOBJECT('MSXML2.DomDocument') goXML.Load("Formats.XML") gcolElements = goxml.getElementsByTagName("Bank") For Each element In gcolElements ? element.attributes.item(0).text,element.attributes.item(1).text EndFor
But for each bank I need to iterate through the content entries for that bank and extract the text and value attributes. So far I cannot see how to do it. Any suggestions would be very welcome
Many thanks
Paul Newton
What comes up with goxml.GetChildNode or anything with Node? HTH
On Mon, Mar 21, 2016 at 11:21 AM, Paul Newton Paul.Newton@pegasus.co.uk wrote:
Hi all
I have the following simplified XML
<Formats> <Bank id="1" name="AIB"> <Content text = "line1" value="value1"/> <Content text = "line2" value="value2"/> </Bank> <Bank id="2" name="Barclays"> <Content text = "line1" value="value1"/> <Content text = "line2" value="value2"/> <Content text = "line3" value="value3"/> </Bank> </Formats>
With the following code I can iterate through the banks and display their names as follows
goXML = CREATEOBJECT('MSXML2.DomDocument') goXML.Load("Formats.XML") gcolElements = goxml.getElementsByTagName("Bank") For Each element In gcolElements ? element.attributes.item(0).text,element.attributes.item(1).text EndFor
But for each bank I need to iterate through the content entries for that bank and extract the text and value attributes. So far I cannot see how to do it. Any suggestions would be very welcome
Many thanks
Paul Newton
[excessive quoting removed by server]
Goxml doesn't have GetChildNode
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Stephen Russell Sent: 21 March 2016 16:25 To: profoxtech@leafe.com Subject: Re: Need help with parsing XML
What comes up with goxml.GetChildNode or anything with Node? HTH
On Mon, Mar 21, 2016 at 11:21 AM, Paul Newton Paul.Newton@pegasus.co.uk wrote:
Hi all
I have the following simplified XML
<Formats> <Bank id="1" name="AIB"> <Content text = "line1" value="value1"/> <Content text = "line2" value="value2"/> </Bank> <Bank id="2" name="Barclays"> <Content text = "line1" value="value1"/> <Content text = "line2" value="value2"/> <Content text = "line3" value="value3"/> </Bank> </Formats>
With the following code I can iterate through the banks and display their names as follows
goXML = CREATEOBJECT('MSXML2.DomDocument') goXML.Load("Formats.XML") gcolElements = goxml.getElementsByTagName("Bank") For Each element In gcolElements ? element.attributes.item(0).text,element.attributes.item(1).text EndFor
But for each bank I need to iterate through the content entries for that bank and extract the text and value attributes. So far I cannot see how to do it. Any suggestions would be very welcome
Many thanks
Paul Newton
[excessive quoting removed by server]
Paul Newton wrote on 2016-03-21:
Hi all
I have the following simplified XML
<Formats> <Bank id="1" name="AIB"> <Content text = "line1" value="value1"/> <Content text = "line2" value="value2"/> </Bank> <Bank id="2" name="Barclays"> <Content text = "line1" value="value1"/> <Content text = "line2" value="value2"/> <Content text = "line3" value="value3"/> </Bank> </Formats>
With the following code I can iterate through the banks and display their
names as follows
goXML = CREATEOBJECT('MSXML2.DomDocument') goXML.Load("Formats.XML") gcolElements = goxml.getElementsByTagName("Bank") For Each element In gcolElements ? element.attributes.item(0).text,element.attributes.item(1).text EndFor
But for each bank I need to iterate through the content entries for that
bank and extract the text and value attributes. So far I cannot see how to do it. Any suggestions would be very welcome
Many thanks
Paul Newton
Paul,
There are multiple ways to parse the XML DomDocument. You grabbed all the elements called "Bank", you could then grab the elements called "Content" or loop through the child nodes.
goXML = CREATEOBJECT('MSXML2.DomDocument') goXML.Load("Formats.XML") gcolElements = goxml.getElementsByTagName("Bank") For Each element In gcolElements ? element.attributes.item(0).text,element.attributes.item(1).text IF element.haschildnodes FOR EACH content IN element.childNodes ? content.attributes.item(0).text, content.attributes.item(1).text NEXT ENDIF EndFor
Tracy Pearson PowerChurch Software
Many, many thanks Tracy - I thought I had tried something along those lines without success but your suggestion fits the bill perfectly.
Paul Newton
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Tracy Pearson Sent: 21 March 2016 16:54 To: profoxtech@leafe.com Subject: RE: Need help with parsing XML
Paul Newton wrote on 2016-03-21:
Hi all
I have the following simplified XML
<Formats> <Bank id="1" name="AIB"> <Content text = "line1" value="value1"/> <Content text = "line2" value="value2"/> </Bank> <Bank id="2" name="Barclays"> <Content text = "line1" value="value1"/> <Content text = "line2" value="value2"/> <Content text = "line3" value="value3"/> </Bank> </Formats>
With the following code I can iterate through the banks and display their
names as follows
goXML = CREATEOBJECT('MSXML2.DomDocument') goXML.Load("Formats.XML") gcolElements = goxml.getElementsByTagName("Bank") For Each element In gcolElements ? element.attributes.item(0).text,element.attributes.item(1).text EndFor
But for each bank I need to iterate through the content entries for that
bank and extract the text and value attributes. So far I cannot see how to do it. Any suggestions would be very welcome
Many thanks
Paul Newton
Paul,
There are multiple ways to parse the XML DomDocument. You grabbed all the elements called "Bank", you could then grab the elements called "Content" or loop through the child nodes.
goXML = CREATEOBJECT('MSXML2.DomDocument') goXML.Load("Formats.XML") gcolElements = goxml.getElementsByTagName("Bank") For Each element In gcolElements ? element.attributes.item(0).text,element.attributes.item(1).text IF element.haschildnodes FOR EACH content IN element.childNodes ? content.attributes.item(0).text, content.attributes.item(1).text NEXT ENDIF EndFor
Tracy Pearson PowerChurch Software
[excessive quoting removed by server]
Hi, for interest, I've been playing around with developing a web photo gallery. From javascript (which I know a little bit, and am beginning to accept with reservations) this led me to jQuery (which I probably should know but don't) and (for more understanding) on to CSS Selector.... Over the years I have come to accept the OO concept (with the mental reservation that libraries of mutable functions were easier to understand and probably much more efficient). One of the reasons I accepted OO was the simpler interface and less obfustication, even at the cost of efficiency. But this makes APL look intuitive:- http://www.w3schools.com/cssref/css_selectors.asp you have to remember a dozen or so single character prefixes and what they do?
It may not be the fault of CSS Selectors or jQuery, but if not it surely supports my long-standing view that the DOM is an abomination!
Hi Andy:
Without Intellisense you surely can't remember all VFP form events and properties, but you know that you can do something and can look at the help for the proper syntax, even for commands.
This is the same, you read it once or twice then you know that you can do something, so next time you use intellisense for looking at the options or look at the help for getting the proper syntax.
I don't see this as something "too" difficult to get, but surely can't be analyzed from the VFP perspective, because you can do with CSS many things that you can't with VFP or without many lines of programming in VFP.
If you start thinking of a way to select "elements" or "properties" nested into objects with a syntax smaller and simpler than a select-sql, you surely can arrive at something very similar to this syntax too.
I preffer this: [title~=flower]
Than this: Selects all elements where attribute = "title" and "flower" $ value
And this is only a small example. They can be too much complex than this, and a very long SQL do not add any simplicity to this use case.
Regards.-
2016-03-29 12:11 GMT+02:00 AndyHC jarndice@gmail.com:
Hi, for interest, I've been playing around with developing a web photo gallery. From javascript (which I know a little bit, and am beginning to accept with reservations) this led me to jQuery (which I probably should know but don't) and (for more understanding) on to CSS Selector.... Over the years I have come to accept the OO concept (with the mental reservation that libraries of mutable functions were easier to understand and probably much more efficient). One of the reasons I accepted OO was the simpler interface and less obfustication, even at the cost of efficiency. But this makes APL look intuitive:- http://www.w3schools.com/cssref/css_selectors.asp you have to remember a dozen or so single character prefixes and what they do?
It may not be the fault of CSS Selectors or jQuery, but if not it surely supports my long-standing view that the DOM is an abomination!
[excessive quoting removed by server]
Hi, looks like you're agreeing with me that the DOM is "a riddle wrapped in a mystery inside an enigma..." - but as Churchill said: "It is a riddle wrapped in a mystery inside an enigma: but perhaps there is a key....."
iow these are tools to crack a problem that shouldn't have been created in the first place! <g>
On 29/03/2016 16:19, Fernando D. Bozzo wrote:
Hi Andy:
Without Intellisense you surely can't remember all VFP form events and properties, but you know that you can do something and can look at the help for the proper syntax, even for commands.
This is the same, you read it once or twice then you know that you can do something, so next time you use intellisense for looking at the options or look at the help for getting the proper syntax.
I don't see this as something "too" difficult to get, but surely can't be analyzed from the VFP perspective, because you can do with CSS many things that you can't with VFP or without many lines of programming in VFP.
If you start thinking of a way to select "elements" or "properties" nested into objects with a syntax smaller and simpler than a select-sql, you surely can arrive at something very similar to this syntax too.
I preffer this: [title~=flower]
Than this: Selects all elements where attribute = "title" and "flower" $ value
And this is only a small example. They can be too much complex than this, and a very long SQL do not add any simplicity to this use case.
Regards.-
2016-03-29 12:11 GMT+02:00 AndyHC jarndice@gmail.com:
Hi, for interest, I've been playing around with developing a web photo gallery. From javascript (which I know a little bit, and am beginning to accept with reservations) this led me to jQuery (which I probably should know but don't) and (for more understanding) on to CSS Selector.... Over the years I have come to accept the OO concept (with the mental reservation that libraries of mutable functions were easier to understand and probably much more efficient). One of the reasons I accepted OO was the simpler interface and less obfustication, even at the cost of efficiency. But this makes APL look intuitive:- http://www.w3schools.com/cssref/css_selectors.asp you have to remember a dozen or so single character prefixes and what they do?
It may not be the fault of CSS Selectors or jQuery, but if not it surely supports my long-standing view that the DOM is an abomination!
[excessive quoting removed by server]
Well, it's like explaining to a newbie the phantom record, or why you can RECALL deleted records. It's a quirk of the nature of the beast.
CSS is the worst possible solution to applying style to HTML, except all of the others, to also mis-paraphrase Sir Winston.
CSS has a consistent set of rules, and there is power in understanding how they can be manipulated. There are amazing and wonderful web pages created out of elegant, quirky and sometimes hacky application of CSS.
"Introduction to HTML5 and CSS3" was the topic of The Last Tour of talks I gave, 2007-2014, to Ruby, Linux and WordPress groups. I'm a fan.
On Tue, Mar 29, 2016 at 7:54 AM, AndyHC jarndice@gmail.com wrote:
Hi, looks like you're agreeing with me that the DOM is "a riddle wrapped in a mystery inside an enigma..." - but as Churchill said: "It is a riddle wrapped in a mystery inside an enigma: but perhaps there is a key....."
iow these are tools to crack a problem that shouldn't have been created in the first place! <g>
On 29/03/2016 16:19, Fernando D. Bozzo wrote:
Hi Andy:
Without Intellisense you surely can't remember all VFP form events and properties, but you know that you can do something and can look at the help for the proper syntax, even for commands.
This is the same, you read it once or twice then you know that you can do something, so next time you use intellisense for looking at the options or look at the help for getting the proper syntax.
I don't see this as something "too" difficult to get, but surely can't be analyzed from the VFP perspective, because you can do with CSS many things that you can't with VFP or without many lines of programming in VFP.
If you start thinking of a way to select "elements" or "properties" nested into objects with a syntax smaller and simpler than a select-sql, you surely can arrive at something very similar to this syntax too.
I preffer this: [title~=flower]
Than this: Selects all elements where attribute = "title" and "flower" $ value
And this is only a small example. They can be too much complex than this, and a very long SQL do not add any simplicity to this use case.
Regards.-
2016-03-29 12:11 GMT+02:00 AndyHC jarndice@gmail.com:
Hi, for interest, I've been playing around with developing a web photo gallery. From javascript (which I know a little bit, and am beginning to accept with reservations) this led me to jQuery (which I probably should know but don't) and (for more understanding) on to CSS Selector.... Over the years I have come to accept the OO concept (with the mental reservation that libraries of mutable functions were easier to understand and probably much more efficient). One of the reasons I accepted OO was the simpler interface and less obfustication, even at the cost of efficiency. But this makes APL look intuitive:- http://www.w3schools.com/cssref/css_selectors.asp you have to remember a dozen or so single character prefixes and what they do?
It may not be the fault of CSS Selectors or jQuery, but if not it surely supports my long-standing view that the DOM is an abomination!
[excessive quoting removed by server]
I think anyone who can sort out that:
Customer.Lastname was a field in a cursor Form.Height was a property of an object oWord.Print is calling a method on a COM Object
ought to be grateful for a little variation to provide clues.
There's also containership, hierarchy, specificity and order of processing ("last one wins!")
You could either think this is a steaming mess, or a sophisticated declarative language.
On Tue, Mar 29, 2016 at 9:04 AM, Ted Roche tedroche@gmail.com wrote:
Well, it's like explaining to a newbie the phantom record, or why you can RECALL deleted records. It's a quirk of the nature of the beast.
CSS is the worst possible solution to applying style to HTML, except all of the others, to also mis-paraphrase Sir Winston.
CSS has a consistent set of rules, and there is power in understanding how they can be manipulated. There are amazing and wonderful web pages created out of elegant, quirky and sometimes hacky application of CSS.
"Introduction to HTML5 and CSS3" was the topic of The Last Tour of talks I gave, 2007-2014, to Ruby, Linux and WordPress groups. I'm a fan.
On Tue, Mar 29, 2016 at 7:54 AM, AndyHC jarndice@gmail.com wrote:
Hi, looks like you're agreeing with me that the DOM is "a riddle wrapped in a mystery inside an enigma..." - but as Churchill said: "It is a riddle wrapped in a mystery inside an enigma: but perhaps there is a key....."
iow these are tools to crack a problem that shouldn't have been created in the first place! <g>
On 29/03/2016 16:19, Fernando D. Bozzo wrote:
Hi Andy:
Without Intellisense you surely can't remember all VFP form events and properties, but you know that you can do something and can look at the help for the proper syntax, even for commands.
This is the same, you read it once or twice then you know that you can do something, so next time you use intellisense for looking at the options or look at the help for getting the proper syntax.
I don't see this as something "too" difficult to get, but surely can't be analyzed from the VFP perspective, because you can do with CSS many things that you can't with VFP or without many lines of programming in VFP.
If you start thinking of a way to select "elements" or "properties" nested into objects with a syntax smaller and simpler than a select-sql, you surely can arrive at something very similar to this syntax too.
I preffer this: [title~=flower]
Than this: Selects all elements where attribute = "title" and "flower" $ value
And this is only a small example. They can be too much complex than this, and a very long SQL do not add any simplicity to this use case.
Regards.-
2016-03-29 12:11 GMT+02:00 AndyHC jarndice@gmail.com:
Hi, for interest, I've been playing around with developing a web photo gallery. From javascript (which I know a little bit, and am beginning to accept with reservations) this led me to jQuery (which I probably should know but don't) and (for more understanding) on to CSS Selector.... Over the years I have come to accept the OO concept (with the mental reservation that libraries of mutable functions were easier to understand and probably much more efficient). One of the reasons I accepted OO was the simpler interface and less obfustication, even at the cost of efficiency. But this makes APL look intuitive:- http://www.w3schools.com/cssref/css_selectors.asp you have to remember a dozen or so single character prefixes and what they do?
It may not be the fault of CSS Selectors or jQuery, but if not it surely supports my long-standing view that the DOM is an abomination!
[excessive quoting removed by server]
Funny you should say that. I wanted to make a photo gallery that meant I could just make a directory and put photos in it and the single aspx did the work for me. Took some thinking about but I got there. Al
Allen Pollard GSL
Hi, for interest, I've been playing around with developing a web photo gallery.
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
On Tue, Mar 29, 2016 at 6:11 AM, AndyHC jarndice@gmail.com wrote:
Hi,
don't) and (for more understanding) on to CSS Selector.... Over the years I have come to accept the OO concept (with the mental reservation that libraries of mutable functions were easier to understand and probably much more efficient). One of the reasons I accepted OO was the simpler interface and less obfustication, even at the cost of efficiency. But this makes APL look intuitive:- http://www.w3schools.com/cssref/css_selectors.asp you have to remember a dozen or so single character prefixes and what they do?
Yes.
Just as with other languages, where you learn containership, inheritance, operator precedence, there is a rich collection, and an 80/20 rule of 80% of the time you can get by knowing 20% of the options, and looking up the rest when you need to.
1. # designates the unique ID of a single item. 2. . specifies a class of items 3. element name (like p or UL) restricts the style assignment to a single element type. 4. Two of these in a row specifies elements within elements, i.e., 5. ul.picklist li specifies listitems contained within an unordered list of class picklist 6. a comma-separated list of selectors means the styles apply to each.
For reference, my mentors who know a lot more about this than me generally recommend against using the site you've cited, and suggest reference.sitepoint.com or dev.mozilla.org for better and more up-to-date info.
Try this site.
http://www.littlewebhut.com/css/css_syntax/
They might even have videos I believe.
On Tue, Mar 29, 2016 at 5:11 AM, AndyHC jarndice@gmail.com wrote:
Hi, for interest, I've been playing around with developing a web photo gallery. From javascript (which I know a little bit, and am beginning to accept with reservations) this led me to jQuery (which I probably should know but don't) and (for more understanding) on to CSS Selector.... Over the years I have come to accept the OO concept (with the mental reservation that libraries of mutable functions were easier to understand and probably much more efficient). One of the reasons I accepted OO was the simpler interface and less obfustication, even at the cost of efficiency. But this makes APL look intuitive:- http://www.w3schools.com/cssref/css_selectors.asp you have to remember a dozen or so single character prefixes and what they do?
It may not be the fault of CSS Selectors or jQuery, but if not it surely supports my long-standing view that the DOM is an abomination!
[excessive quoting removed by server]
On 29-Mar-2016 6:51 PM, Stephen Russell wrote:
Try this site.
http://www.littlewebhut.com/css/css_syntax/
They might even have videos I believe.
Videos? Kernighan https://en.wikipedia.org/wiki/Brian_Kernighan, Ritchie https://en.wikipedia.org/wiki/Dennis_Ritchie,and Codd forfend! <s>
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
You need this instead: https://www.youtube.com/watch?v=DoUQhYDz-Ys
On Tue, Mar 29, 2016 at 8:52 AM, AndyHC jarndice@gmail.com wrote:
On 29-Mar-2016 6:51 PM, Stephen Russell wrote:
Try this site.
http://www.littlewebhut.com/css/css_syntax/
They might even have videos I believe.
Videos? Kernighan https://en.wikipedia.org/wiki/Brian_Kernighan,
Ritchie https://en.wikipedia.org/wiki/Dennis_Ritchie,and Codd forfend!
<s>
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
On 29-Mar-2016 7:25 PM, Stephen Russell wrote:
You need this instead: https://www.youtube.com/watch?v=DoUQhYDz-Y
<g> - but my mental projection of my digital self would probably be in S360 macro assembler (no Intellisense Ted, but you got a Green Card <s>).
btw sorry about the links to K&R - that's what you get for using Google to check the spelling of names!