> Well, look [at libxml] and tell how to do the above from it quickly. You can't.
Bullshit. Any reason for writing such flamebait? On /. you would have been voted into oblivion for that.
use XML::LibXML;
my $dom = XML::LibXML->load_xml(IO => STDIN);
$_->setAttribute(color => 'red')
for $dom->findnodes('//item[@color="orange"]');
print $dom->toString;
It is bullshit, as many commenters already noted, but it is also my experience back then, in the light of an article's meaning. The experience was bullshit, let that sink in. Perl, google, CPAN documentation on the first two (big) modules gave no clear reason to not s/// and go deeper. I chose s///. Was(am) I smart? Probably not so much. Was all of that inviting me to s///? Yes. And it worked, I had to parse these stupid enormous xmls into my computer parts warehouse where I worked at, and had no time to read all the manuals while clients crowded at the door.
Look at the doc again, where is your snippet there? Down 2 levels of links probably. You didn't write this right the first time you opened it in your browser. Where is ->findnodes() reference? I skimmed ::DOM, ::Document, ::Element to no avail. Even now my patience is over, while e.g. jQuery made it obvious "$(sel).attr(…)" even though I never really used it nor read its docs.
Lots of misconceptions and wrong statements. It gives me a headache!
When I said bullshit, I meant to express that you are talking nonsense regarding the quoted part. I proved that it is nonsense by producing the desired code. You don't get to redefine the word bullshit how it suits you after the fact.
You previously wrote that "you [ed: that is, the other HN readers] can't" "tell how to do the above from [the documentation] quickly". But now it turns out that you meant to express that "I [that is, wruza] can't" use the documentation in the specified way. That's a completely different idea.
> Perl, google, CPAN documentation […] gave no clear reason to not s/// and go deeper.
This is the same abdication of personal responsibility as a programmer as shown in the article. I won't stand for it. The premise of "shepherding" as described is plain wrong: a programming language or its documentation can't make one do anything. It is not a living being with will and intentionality, it is just a thing. Anthropomorphising a thing is not a rational way of looking at the world, but belongs into the realm of magical thinking because this idea allows one to say "a thing made me do something" when the reality is that someone chose to react to the thing in the way he did, and the responsibility for doing so falls on him alone.
The true meaning of "shepherding" involves another human being. I do not rely just on Web search engines and documentation (i.e. technical means) as I have a healthy amount of scepticism about my own ability, so I can take a moment to talk to another programmer about my idea of XML parsing, and if he sees regex, he will point out the potential flaws and set me right. Code review is a thing, problem averted by social means. Given the results, I suppose you did not talk a programmer. I suppose you also did not bother to stop for a moment and think "TIMTOWTDI, am I doing this in the best possible way?". If that is so, then you can see there is room for growth and improvement. This is the difference between banging with one's car against the crash barriers on the mountain to keep it on the road and taking the time to learn to drive properly.
The reason why the concept of regex for XML has not been eradicated yet even though we could do so by expending a bit of technical and social effort is that we have come to agree that Perl tries to be for everyone. I will not harshly criticise this practice or not say anything at all when beginners or non-professional programmers do it, but you cannot be afforded this protection, the expectations of conduct are higher.
> [I] had no time to read all the manuals while clients crowded at the door
The correct way to handle this situation would have been to take time management into your own hand (again, responsibility as an adult in a work setting) and say something along the lines: "Pardon, I have work to do and need to concentrate. I cannot be productive when I am perpetually distracted by people standing in my door. I need to ask you to go away for now. Please send me an email and we can appoint a meeting time for discussing what's on your mind. If you have something urgent, I cannot deal with it right now, notify my substitute colleague/my manager/my boss (as appropriate)."
And there you have 5 minutes of free time with a clear head and can get an overview of the documentation.
> look at the doc again, where is your snippet there? Down 2 levels of links probably.
That's false. Each method is down one link, i.e. directly reachable from the main documentation page.
> Where is ->findnodes() reference? I skimmed ::DOM, ::Document, ::Element to no avail. Even now my patience is over
If my junior programmers came to me with these words I would chew them out for not really trying. Randomly clicking links is not a structured and goal-oriented way to get at the desired information of which you know that it exists. Use search instead; off the top of my head:
These solutions are not particularly ergonomic, there are better ones, but these are guaranteed to be available.
> You didn't write this right the first time you opened it in your browser.
You would be well advised to stop with your inflammatory assertions because you'll get to painfully regret such behaviour one day. You can always write "I assume" or "AFAICT" and not rile people up.
The truth is, I did write this right the first time. I examined working example code and used the online documentation to modify the code to my needs. The tutorial that is now prominently linked "above the fold" in the main documentation page did not exist back then, so the example code must have been something else, but I remember it being something similar in spirit. A whole lot of people do the same what I just described as evidenced by the strongly memetic nature of Stack Overflow.
Bullshit. Any reason for writing such flamebait? On /. you would have been voted into oblivion for that.